Last active
January 3, 2022 14:27
-
-
Save KenanBek/e1eb0ea9a2245936bec5f3d075484e93 to your computer and use it in GitHub Desktop.
Rename local and remote Git branch names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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