Skip to content

Instantly share code, notes, and snippets.

@aflashyrhetoric
Created September 3, 2019 20:27
Show Gist options
  • Save aflashyrhetoric/91c902e129e193feb45968e487da190f to your computer and use it in GitHub Desktop.
Save aflashyrhetoric/91c902e129e193feb45968e487da190f to your computer and use it in GitHub Desktop.
#!/bin/bash
# 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]}"
done
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