Reputation: 28384
I named a branch Name
instead of name
and would like to change it to the latter.
I tried renaming the branch locally:
git branch -m tmp
Deleting the branch on github:
git push origin --delete Name
Renaming the temp branch:
git branch -m name
Pushing the branch to github:
git push origin name
But when I push the branch to github, I get this output:
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/xx/xx.git
* [new branch] name -> Name
Why did github rename the branch when I pushed it? How can I rename my branch from Name
to name
?
Upvotes: 11
Views: 6784
Reputation: 283
First, from the branch you want to rename you do the following:
git branch -m name
Then we need to delete the old name branch from the remote and push the new branch name from the local to the remote branch.
git push origin :Name name
Last you need to switch to the branch and then:
git push origin -u name
Referance: https://multiplestates.wordpress.com/2015/02/05/rename-a-local-and-remote-branch-in-git/
Upvotes: 0
Reputation: 265241
Use git push origin old_name:new_name
to define how the branch will be called on the server. You probably have the remote branch name in your .git/config file which was not updated.
Upvotes: 7