top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to rename branch in git on local and remote server?

+1 vote
476 views
How to rename branch in git on local and remote server?
posted Nov 24, 2016 by Amit Kumar Pandey

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+2 votes

Local Server

If you want to rename a branch while pointed to any branch, do :

git branch -m <oldname> <newname>

If you want to rename the current branch, you can do:

git branch -m <newname>

Delete the oldname remote branch and push the newname local branch.

git push origin :oldname newname

Reset the upstream branch for the newname local branch.
Switch to the branch and then:

git push origin -u newname
answer Nov 24, 2016 by Salil Agrawal
...