Skip to content

Instantly share code, notes, and snippets.

@tjmw
Last active December 16, 2015 06:19
Show Gist options
  • Save tjmw/5390765 to your computer and use it in GitHub Desktop.
Save tjmw/5390765 to your computer and use it in GitHub Desktop.
Show (up to a max of) 5 most recently checked out branches in Git
git reflog \
| awk '{ print $3, $NF }' \
| grep "^checkout:" \
| awk '{ print $2 }' \
| egrep -v '^([0-9a-f]{40}|[0-9a-f]{7}$)' \
| perl -ne 'print unless $a{$_}++' \
| head -5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment