Skip to content

Instantly share code, notes, and snippets.

@MEGApixel23
Forked from lttlrck/gist:9628955
Last active August 23, 2018 10:06
Show Gist options
  • Save MEGApixel23/bc6405f138c519e54c8075423dcee6f3 to your computer and use it in GitHub Desktop.
Save MEGApixel23/bc6405f138c519e54c8075423dcee6f3 to your computer and use it in GitHub Desktop.
Rename git branch locally and remotely
#!/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