Implement a GIT Branch Checkout History
·1 min
![](/blog/2021/02/22/implement-a-git-checkout-branch-command/cover_hu7dabfee9775da7682de8ad5ac5e0fd91_3703135_660x0_resize_q75_box.jpg)
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