Skip to content

Instantly share code, notes, and snippets.

@bdd
Forked from evnm/gcb
Last active December 29, 2015 07:29
Show Gist options
  • Save bdd/7635986 to your computer and use it in GitHub Desktop.
Save bdd/7635986 to your computer and use it in GitHub Desktop.
a shorter, faster and a bit more helpful version of gcb.sh
#! /bin/sh
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