Skip to content

Instantly share code, notes, and snippets.

@mcjim
Created February 28, 2018 14:29
Show Gist options
  • Save mcjim/4b610bb76e8d3095b97a4535e63d3644 to your computer and use it in GitHub Desktop.
Save mcjim/4b610bb76e8d3095b97a4535e63d3644 to your computer and use it in GitHub Desktop.
Script to easily jump to recent git branches
#!/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