Skip to content

Instantly share code, notes, and snippets.

@mikiyaf
Last active November 13, 2017 00:59
Show Gist options
  • Select an option

  • Save mikiyaf/55882bc721187f224a8738e1952034f2 to your computer and use it in GitHub Desktop.

Select an option

Save mikiyaf/55882bc721187f224a8738e1952034f2 to your computer and use it in GitHub Desktop.
fbr - checkout git branch (including remote branches), sorted by most recent commit, limit 30 Last branches
fbr() {
local branches branch
branches=$(git for-each-ref --count=30 --sort=-committerdate refs/heads/ --format="%(refname:short)") &&
branch=$(echo "$branches" |
fzf-tmux -d $(( 2 + $(wc -l <<< "$branches") )) +m) &&
git checkout $(echo "$branch" | sed "s/.* //" | sed "s#remotes/[^/]*/##")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment