Skip to content

Instantly share code, notes, and snippets.

@evnm
Last active December 29, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save evnm/7634093 to your computer and use it in GitHub Desktop.
Save evnm/7634093 to your computer and use it in GitHub Desktop.
A fuzzy `git checkout`.
#! /bin/sh
# A fuzzy `git checkout`.
match=`git rev-parse --abbrev-ref --branches="*$1*"`
case `wc -w <<< "$match" | tr -d ' '` in
"0") echo "error: '$1' did not match any branch." 2>&1 ;;
"1") git checkout $match ;;
*) echo "error: '$1' is ambigious among:\n$match" 2>&1
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment