Skip to content

Instantly share code, notes, and snippets.

@imesh
Last active December 9, 2016 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imesh/50e1a2c7ebeccc8ffb0776f27d96bc17 to your computer and use it in GitHub Desktop.
Save imesh/50e1a2c7ebeccc8ffb0776f27d96bc17 to your computer and use it in GitHub Desktop.
Rename a Git branch
#!/bin/bash
old_name="old-branch-name"
new_name="new-branch-name"
git checkout ${old_name}
git branch -m ${old_name} ${new_name}
git push origin :${old_name} ${new_name}
git push origin -u ${new_name}
echo "Branch ${old_name} renamed to ${new_name}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment