Skip to content

Instantly share code, notes, and snippets.

@BlackHole1
Created March 1, 2024 08:31
Show Gist options
  • Save BlackHole1/f37facb57dca1b25b56729e309aae15c to your computer and use it in GitHub Desktop.
Save BlackHole1/f37facb57dca1b25b56729e309aae15c to your computer and use it in GitHub Desktop.
git checkout with fzf
# Ref: https://x.com/naoya_ito/status/1763034484843381187?s=20
git for-each-ref refs/tags refs/heads --sort=-committerdate --format="%(if:equals=commit)%(objecttype)%(then)branch%(else)%(objecttype)%(end)˞%(HEAD) %(refname:lstrip=2)˞%(objectname:short)˞%(if)%(upstream:remoteref)%(then) [%(upstream:lstrip=2)]%(end) %(subject) %(upstream:track)" | column -t -s ˞ | fzf -i --layout=reverse --preview-window=down:50% --preview="git show --no-patch --pretty=format:'Date: %ci (%cr)%nAuthor: %an <%ae>%nHash: %H%nBody:%n%b' {2}" | tr '*' ' ' | awk '{print $2}' | xargs -o git checkout
@BlackHole1
Copy link
Author

Preview:
mnggiflab-compressed-03-01 15 03(3)

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