Created
September 27, 2019 09:23
-
-
Save chrismatix/f6ea4ed4c67a614f80dad415a80e0df2 to your computer and use it in GitHub Desktop.
Checkout branches recently checked out in git
This file contains hidden or 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
checkout_recent() { | |
LASTN=${1:-5} | |
git checkout $(git reflog | egrep -io 'moving from ([^[:space:]]+)' | awk '{ print $3 }' | awk ' !x[$0]++' | egrep -v '^[a-f0-9]{40}$' | head -n $LASTN | fzf) | |
} | |
alias gre="checkout_recent" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to your
.bash_profile
or.zshrc
to checkout branches recently checked out with git. Requires fzf for a nice selection.