Skip to content

Instantly share code, notes, and snippets.

@gko
Created May 1, 2020 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gko/fc9953db773408e048eea16f0d07441e to your computer and use it in GitHub Desktop.
Save gko/fc9953db773408e048eea16f0d07441e to your computer and use it in GitHub Desktop.
rename git branch (local and remote)
#!/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