Skip to content

Instantly share code, notes, and snippets.

@evnm evnm/gcb
Last active Dec 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.