Skip to content

Instantly share code, notes, and snippets.

@liamja
Created January 13, 2026 11:13
Show Gist options
  • Select an option

  • Save liamja/64128ea0cf4344f474553112ea2f5e7a to your computer and use it in GitHub Desktop.

Select an option

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)
[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)}'
@liamja
Copy link
Copy Markdown
Author

liamja commented Jan 13, 2026

git lbs
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment