Skip to content

Instantly share code, notes, and snippets.

@dflima
Last active November 6, 2017 20:52
Show Gist options
  • Save dflima/f8207d2632dc4c56a42d16e460461b77 to your computer and use it in GitHub Desktop.
Save dflima/f8207d2632dc4c56a42d16e460461b77 to your computer and use it in GitHub Desktop.
Git alias to rename local and remote branches
# Put the code below on your .gitconfig file, under "alias" section.
# Usage:
# git rename old_branch_name new_branch_name
[alias]
rename="!f() { git branch "$2" origin/"$1" && git push origin --set-upstream "$2" && git push origin --delete "$1"; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment