Implement a GIT Branch Checkout History
·1 min

Take this alias
# .gitconfig
[alias]
hist = "!f() { for i in $(seq 9 $END); do echo "@{-$i}: `git rev-parse --abbrev-ref @{-$i}`"; done }; f "
This will show the last 9 branches you have checked out with the abbreviation to switch to it.
❯ git hist
@{-1}: main
@{-2}: add-healthchecks-io
@{-3}: main
@{-4}: fix-visible-flag
@{-5}: main
@{-6}: implement-join-code
@{-7}: main
@{-8}: fix-visible-flag
@{-9}: main
You can of course use the branch name to check it out, or use the abbreviation in front of it git checkout @{-6}
will check out implement-join-code
.
Attribution: Trees Avenue Road by DarkmoonArt_de