Implement a GIT Branch Checkout History

Take this alias

# .gitconfig

  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.

Image by DarkmoonArt_de from Pixabay