Skip to content

Instantly share code, notes, and snippets.

@uilian
Created May 5, 2021 12:26
Show Gist options
  • Save uilian/ece87516fb2f2c9a92327a7a74dedad7 to your computer and use it in GitHub Desktop.
Save uilian/ece87516fb2f2c9a92327a7a74dedad7 to your computer and use it in GitHub Desktop.
Rename git branch local and remote
git checkout branch_to_be_renamed
git branch -m branch_to_be_renamed new_branch_name
git push origin --delete branch_to_be_renamed
git push origin -u new_branch_name
######
# -u, --set-upstream
# For every branch that is up to date or successfully pushed, add upstream (tracking)
# reference, used by argument-less git-pull(1) and other commands. For more information, see
# branch.<name>.merge in git-config(1).
#####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment