git branch -a. Scroll. Squint. Find the one you
want. Carefully retype it — typo it.
git checkout sudarshan/refactor-api-cli-helpers. Option + Backspace a few times and try again. Strip the
remotes/origin/ prefix you forgot about. Try
again.
This is maybe forty seconds of friction. It is also forty seconds you will pay every single time you switch branches, for the rest of your life as an engineer.
fzf, strip the noise, and check out your
selection. Fifteen lines of shell. Branch switching
reduced to one keystroke and a fuzzy search,
forever.
gbf() {
local branch
branch=$(git branch -a --color=never | sed 's/^[* ] //' | sed 's|remotes/||' | sort -u | fzf --height=20 --reverse --prompt="Select branch: ")
if [[ -n "$branch" ]]; then
git checkout "${branch#origin/}"
fi
}
The best investment you can make is in the infra that holds up your day to day. Two minutes now, every time, so that future-you can thank you every single time.