Skip to content

Instantly share code, notes, and snippets.

Created September 3, 2019 20:27
What would you like to do?
# lists the branches in order and lets you select
# which one to checkout
branches=( $(git for-each-ref refs/heads | cut -d '/' -f 3-) )
for i in "${!branches[@]}"; do
echo "$i) ${branches[$i]}"
echo -n "Branch number: "
read bnum
git checkout "${branches[$bnum]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment