Created
February 28, 2018 14:29
-
-
Save mcjim/4b610bb76e8d3095b97a4535e63d3644 to your computer and use it in GitHub Desktop.
Script to easily jump to recent git branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PS3="Switch to a recent branch: " | |
select BRANCH in "exit" $(git for-each-ref --sort=-committerdate --format='%(refname:strip=2)' refs/heads --count=20); | |
do | |
case $BRANCH in | |
exit) | |
echo "Exiting." | |
break | |
;; | |
*) | |
git checkout $BRANCH | |
break | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment