Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active December 5, 2018 17:24
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nepsilon/1f3b1caad6d49364cadccdbc35a96f00 to your computer and use it in GitHub Desktop.
Save nepsilon/1f3b1caad6d49364cadccdbc35a96f00 to your computer and use it in GitHub Desktop.
How to rename a branch in Git? — First published in fullweb.io issue #96

How to rename a branch in Git?

Rename your local foo branch with bar:

git branch -m foo bar

Remember this will add the new branch with you push, but it won’t delete the old foo remote branch.

Add -f --mirror to rename the branch on the remote:

git push -f --mirror

If you just want to remove your remote foo branch, just use:

git push origin :foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment