Fancy navigation through git branches
Apr 14 2021
Navigate through git branches is something any developer do several times when working in a project. This can be quite annoying since it is necessary to remember the name of the branch to move to.
Long story short
A simple but effective approach to make this process easier is using this: git checkout $(git branch -a | fzf)
.
Step by Step
1 - List the available branches with git branch -a
. Only the local branches will be listed.
$ git branch -a
2 - Select a branch from the list with fzf
$ git branch -a | fzf
3 - Use the selected branch for the git checkout:
$ git checkout (git branch -a | fzf)
4 - [Bonus] Integrate it at zsh
. Appending this into ~/.zsh
alias gck="git checkout (git branch -a | fzf)"