-
-
Save MEGApixel23/bc6405f138c519e54c8075423dcee6f3 to your computer and use it in GitHub Desktop.
Rename git branch locally and remotely
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 | |
if [ -z "$1" ] | |
then | |
echo "Specify old branch" | |
fi | |
if [ -z "$2" ] | |
then | |
echo "Specify new branch" | |
fi | |
git branch -m $1 $2 # Rename branch locally | |
git push origin :$1 # Delete the old branch | |
git push --set-upstream origin $2 # Push the new branch, set local branch to track the new remote | |
git push origin $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment