Created
January 13, 2026 11:13
-
-
Save liamja/64128ea0cf4344f474553112ea2f5e7a to your computer and use it in GitHub Desktop.
Show recent branches in Git with git lb and git lbs (requires fzf)
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
| [alias] | |
| lbs = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf \"%s\\t%s\\n\", $1, substr($2, 1, length($2)-1)}' | fzf --with-nth=1.. --preview 'git log --oneline --color=always -5 {1}' --preview-window=right:50% | cut -f1 | xargs -r git checkout | |
| lb = !git reflog show --pretty=format:'%gs ~ %gd' --date=relative | grep 'checkout:' | grep -oE '[^ ]+ ~ .*' | awk -F~ '!seen[$1]++' | head -n 10 | awk -F' ~ HEAD@{' '{printf(\" \\033[33m%s: \\033[37m %s\\033[0m\\n\", substr($2, 1, length($2)-1), $1)}' |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git lbs