Skip to content

Instantly share code, notes, and snippets.

@srsholmes
Created November 23, 2023 15:58
Show Gist options
  • Save srsholmes/5607e26c187922878943c50edfb245ef to your computer and use it in GitHub Desktop.
Save srsholmes/5607e26c187922878943c50edfb245ef to your computer and use it in GitHub Desktop.
Recent git branches
function grecent() {
local branches branch
branches=$(git branch --sort=-committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]') \
&& branch=$(echo "$branches" | fzf --ansi) \
&& branch=$(echo "$branch" | awk '{print $1}' | tr -d '*') \
&& git checkout "$branch"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment