How to rename a branch name in the remote git server?

Posted on In QA, Tutorial

How to rename a branch name in the remote git server? For example, I made a mistake to push a branch named ood-name to the git server while I intended to name it old-name.

How to rename the branch name ood-name on the remote git server?

You may change the remote git server’s branch name as follows.

$ git checkout ood-name # check out the branch
$ git branch -m old-name # change local branch name
# push local old-name to remote ood-name and change the remote branch name
$ git push origin :ood-name old-name

If everything went well, the remote branch should have been changed accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *