2 ms·
fzf is super useful for navigating and switching git branches I realised today [1] function gbll(){ local tags branches target branches=$( gi
by calmoo 4y ago
fzf is super useful for navigating and switching git branches I realised today
[1]
function gbll(){
local tags branches target
branches=$(
git --no-pager branch --sort=-committerdate \
--format="%(if)%(HEAD)%(then)%(else)%(if:equals=HEAD)%(refname:strip=3)%(then)%(else)%1B[0;34;1mbranch%09%1B[m%(refname:short)%(end)%(end)" \
| sed '/^$/d') || return
tags=$(
git --no-pager tag | awk '{print "\x1b[35;1mtag\x1b[m\t" $1}') || return
target=$(
(echo "$branches"; echo "$tags") |
fzf --no-hscroll --no-multi -n 2 \
--ansi --preview="git --no-pager log -150 --pretty=format:%s '..{2}'") || return
git checkout $(awk '{print $2}' <<<"$target" )
}
[1]https://github.com/junegunn/fzf/wiki/Examples#git https://github.com/junegunn/fzf/wiki/Examples#git
- kbd 4y agoAgree I use fzf extensively in my git aliases: https://github.com/kbd/setup/blob/master/HOME/.config/git/config https://github.com/kbd/setup/blob/master/HOME/.config/git/co... Perfect example: my "cherry pick" alias: cp = !git pick-branch | xargs git pick-commits | tac | xargs -t git cherry-pick Those "pick-" aliases pop up fzf to let me choose a branch, then commits to cherry pick. No more copying hashes anywhere. Similarly, my alias for git add lets me fzf-select a list of files to stage based on what "git status" reports.
- agilob 4y agohttps://github.com/bigH/git-fuzzy https://github.com/bigH/git-fuzzy