Skip to content

Instantly share code, notes, and snippets.

@KenanBek
Last active January 3, 2022 14:27
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 KenanBek/e1eb0ea9a2245936bec5f3d075484e93 to your computer and use it in GitHub Desktop.
Save KenanBek/e1eb0ea9a2245936bec5f3d075484e93 to your computer and use it in GitHub Desktop.
Rename local and remote Git branch names
# rename
git branch -m new-name # option 1: when renaming the current branch
git branch -m <current_branch_name> <new_branch_name> # option 2: when renaming another branch
# delete old branch
git push origin -d <old_branch_name> # option 1
git push origin :<old_branch_name> # option 2 (shorter)
# unset upstream
git branch --unset-upstream <new_branch_name>
# push remote
git push origin <new_branch_name>
git push oirign -u <new_branch_name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment