Git – How to Rename Branch to Remove Capitalization

gitgit-branchgithub

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?

Best Answer

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.