This is an old revision of the document!
'fzf' is such a great tool, it changes the way how I operate in vim and shell, git checkout autocomplate with branch is great, but it's better to list branches in a menu then choose it, therefore I add below to git config file:
cof = !git for-each-ref --format='%(refname:short)' refs/heads | fzf | xargs git checkout
so this one-liner list all local branches in fzf, then I could type to narrow down, then press enter to check out the selected branch.
Sometimes, I want to checkout remote branch, I use alias below, 'refname:lstrip=3' strips the remote name from branch name ref, so git checkout could figure out and create a local branch to match it.
cofr = !git for-each-ref --format='%(refname:lstrip=3)' refs/remotes | fzf | xargs git checkout
delete-branches = "!git branch | grep -v '\\*' | fzf --multi | xargs git branch --delete --force"
The idea is list all local branches, but remove current branch (it's marked with *), pipe to fzf so user could select them by pressing 'tab', finally pipe to git to delete.
More informative branch list with tip commit message and relative date.
bl = branch --format='%(HEAD) %(color:yellow)%(committerdate:relative)\t%(color:red)%(refname:short)%(color:cyan)\n\t\t%(contents:subject) %(color:green) [%(authorname)]' --sort=-committerdate
pickhash = !git log --abbrev-commit --color=always | fzf --ansi | awk '{print $1}' | pbcopy
edited-files = !git pickhash | xargs -o git show --format="format:" --name-only pickfile = !git edited-files | fzf --sync | sed -e "s#^#`git rev-parse --show-toplevel`/#" | xargs -o vim