Last active
October 27, 2020 17:10
-
-
Save youngchief-btw/f3e2dfa2d701a4555f6c5be383384f31 to your computer and use it in GitHub Desktop.
Rename a Local and Remote Git Branch (ex. master --> main)
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
#!/bin/bash | |
OLD_NAME=master | |
NEW_NAME=main | |
git checkout $OLD_NAME; | |
git branch -m $NEW_NAME; | |
# If already on remote do the following: | |
git push origin -u $NEW_NAME; | |
git push origin --delete $OLD_NAME: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment