TIL

Recent branches with fzf

21.01.2023

Not something I learned today, but i recently configured a alias for recent branches with fuzzy search with fzf. It will show the branches sorted by the date of the head commit when doing git recent. Selecting one with fzf will then do a git checkout of that branch.

Add the following under aliases in gitconfig:

recent = "!git branch --sort=-committerdate --format=\"%(committerdate:relative)%09%(refname:short)\" | fzf --ansi | awk 'BEGIN{FS=\"\t\"} {print $2}' | xargs git checkout"