Loading...
Bytes is my collection of short-form posts, tips, and things I learn as I build software.
If you find yourself switching branches frequently and getting frustrated with typing out long branch names, or hitting tab way too many times to get to the branch you want to switch to, I might just have a solution for you!
This simple bash script will pull a list of your local branches and uses
fzf to fuzzy-find the branch you want
to checkout. The results are sorted by last commit date, so your most
recent branches are right at the top.
branches=$(git for-each-ref --sort=-committerdate --format="%(refname:short)" refs/heads/)
current_branch=$(git symbolic-ref --short HEAD)