Skip to content

How to Rename Git Local and Remote Branches

Joel Meador edited this page Jun 8, 2026 · 1 revision

I forgot to add my ticket number to my branch name, how do I fix this?

Renaming local branch to the new name.

To rename the local branch to the new name, use the git branch command followed by the -m option:

git branch -m <old-name-without-ticket-number> <new-name-DP-5000>

To delete the old branch on remote (suppose, the name of remote is origin, which is by default), use the following command:

git push origin --delete <old-name>

Or you can shorten the process of deleting the remote branch like this:

git push origin :<old-name>

Pushing the new branch to remote...

Then you should push the new branch to remote:

git push origin <new-name>

To reset the upstream branch for the new-name local branch use the -u flag with the git push command:

git push origin -u <new-name>

Home

TODO: can we recreate the tag system here roughly with sections about certain subjects?

Clone this wiki locally