Skip to content

Instantly share code, notes, and snippets.

@alecthegeek
Last active July 14, 2017 13:05
Show Gist options
  • Save alecthegeek/0a958e5242b824155902ac7b94a98051 to your computer and use it in GitHub Desktop.
Save alecthegeek/0a958e5242b824155902ac7b94a98051 to your computer and use it in GitHub Desktop.
Make `git checkout <branch>` into a menu selection
OPS3=$PS3
echo There are multiple branchs in this repo. Please select the one you want to use
PS3='If you're not sure just choose "master" '
select br in $(git branch|sed -e '/^[* ] /s///'); do
[[ -n $br ]] && git checkout $br &&
break
done
PS3=$OPS3
# You can also put this in your git aliases
# com = !"select br in $(git branch|sed -e '/^[* ] /s///'); do [[ -n $br ]] && git checkout $br && break; done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment