Dec 112018

ADM

How to rename a git branch

  • December 11 2018
  • ADM

 

 

How to rename a git branch - git

 

If you need to rename a branch follow the next steps.

Step1 - check your current branch

To check the current branch run the command git status

$ git status
On branch FEATURE-128
nothing to commit, working directory clean

Step2 - Rename your local branch

If you are already on the branch you want to rename:

$ git branch -m <new-name>

If you are on a different branch:

$ git branch -m <old-name> <new-name>

Step3 - Delete old remote branch and push the new local branch

$ git push origin :<old-name> <new-name>

Step4 - Reset the upstream branch

$ git push origin -u new-name

References