3 ms·
I also use fzf as git branch picker :) In my fish_user_key_bindings.fish (but surely adaptable to other shells), I bind it to Alt+G: function fish_user_ke
by ronjouch 7y ago
I also use fzf as git branch picker :)
In my fish_user_key_bindings.fish (but surely adaptable to other shells), I bind it to Alt+G:
function fish_user_key_bindings
bind \eg 'test -d .git; and git checkout (string trim -- (git branch | fzf)); and commandline -f repaint'
bind \eG 'test -d .git; and git checkout (string trim -- (git branch --all | fzf)); and commandline -f repaint'
end
This goes neatly with fzf's default Alt+C binding to navigate to a directory: Alt+C -> go to a git repo, followed by Alt+G -> pick a branch
- StavrosK 7y agoThat is extremely useful (and for fish, which I don't usually see), thank you!
- vbsteven 7y agoIn Bash/Zsh you can do it with `git config --global alias.cof $'!git for-each-ref --format=\''%\(refname:short\)\'' refs/heads | fzf | xargs git checkout'` and then do a checkout with `git cof`