Skip to content

Instantly share code, notes, and snippets.

@abuseofnotation
Created April 8, 2019 07:35
Show Gist options
  • Save abuseofnotation/26f7d626e7ad6f424ceb86634c4d769f to your computer and use it in GitHub Desktop.
Save abuseofnotation/26f7d626e7ad6f424ceb86634c4d769f to your computer and use it in GitHub Desktop.
An interactive command for switching branches.
[alias]
switch = "!branchesString=$(git for-each-ref --sort=-committerdate --count=10 --format='%(refname:short),' refs/heads/) && branches=(${branchesString//,/ }) && for i in ${!branches[@]}; do echo \"$i - ${branches[$i]}\"; done && read -p which: branch && git checkout ${branches[$branch]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment