Created
May 1, 2020 12:00
-
-
Save gko/fc9953db773408e048eea16f0d07441e to your computer and use it in GitHub Desktop.
rename git branch (local and remote)
This file contains hidden or 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
#!/usr/bin/env bash | |
rename_branch() { | |
[[ $# = 2 ]] && local from=$1 || local from=`git symbolic-ref -q --short HEAD` | |
local to=${2:-$1} | |
git branch -m $from $to | |
git push origin :$from $to | |
git push origin -u $to | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment