How To Rename A Branch In Git?

Rename the current branch:

`git branch -m new-branch-name`

Rename a different local branch:

`git branch -m old-branch-name new-branch-name`

Delete the old branch from the remote:

`git push origin –delete old-branch-name`

Push the renamed branch to the remote:

`git push origin new-branch-name`

Set the upstream for the renamed branch:

`git push –set-upstream origin new-branch-name`

If needed, update the remote HEAD reference:

`git remote set-head origin -a`

Suggested for You

Trending Today