Git shortcut to checkout recent branches

If you have fzf Archive installed, you may add an alias such as this to your ~/.bashrc:

alias recent-branch="git for-each-ref --sort=-committerdate --format='%(refname:short)' refs/heads/ |  fzf | sed 's/\* //g' | xargs -I '{}' git checkout {}"

Now whenever you want to switch back and forth between your most recent branches, type recent-branch, select one and press enter.

Michael Leimst├Ądtner 4 months ago
This website uses short-lived cookies to improve usability.
Accept or learn more