![]() In this article, we have learnt how to change name of local branch as well as remote branch in git. In this case also, you will need to reset upstream branch. $ git push origin -u new_dataĪlternatively, you can overwrite remote branch with the following command. Next, push your local branch new_data to remote repository, and reset the upstream branch. Run the following command to delete the remote branch data. However, the old branch still remains in remote. This will create a new branch in our remote (origin) named unicorn-feature. In our case, the command would be: git push -set-upstream origin unicorn-feature. git push -set-upstream origin .We need to delete the remote branch with old name and then push the local branch with new name. You simply treat the branch - with the new name - as a new branch, and push the branch to remote. However, there is no direct way to rename a remote branch. Otherwise, it can lead to errors and confusion later on when you push/pull commits. Please note, if you have a remote branch corresponding to your local branch, then when you rename the local branch, you need to also rename its remote counterpart. You can verify the branch names with the following command. Rename data and new_data in the above commands with your old and new branch names. This creates a new branch with a new name in the remote. Where you replace the with the new name of your branch. If you want to rename a different local branch (that is NOT currently checked out): git branch -m .![]() Then you can rename branch data to new_data with the following command. Once youâve changed the name of your local branch, you can push it to the upstream and reset the upstream branch. The above command will rename your old branch to new branch.Īlternatively, you can switch to master branch. Next rename data branch using git rename command, which has the following syntax. Then checkout data branch with the following command. Let us say you want to rename branch data to new_data. Here are the steps to rename local & remote branch. In this article, we will learn how to rename local & remote branches in git. You can easily do this using git branch command. Sometimes you may want to change the name of your git branches.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |