Skip to content

Instantly share code, notes, and snippets.

@ejmr
Created September 9, 2015 08:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejmr/75b5b624396d326d5d62 to your computer and use it in GitHub Desktop.
Save ejmr/75b5b624396d326d5d62 to your computer and use it in GitHub Desktop.
Checkout a Git Branch Using Fuzzy-Selection
#!/bin/sh
#
# git pick-branch
#
# This command checks out a branch, using the commnad `pick` to
# provide fuzzy-selection of the branch names.
#
# https://github.com/thoughtbot/pick
#
######################################################################
git branch -a \
| sed "s:remotes/::" \
| sed "s:origin/::" \
| grep -v "HEAD" \
| cut -c 3- \
| sort -u \
| pick \
| xargs git checkout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment