Created
June 6, 2014 04:05
-
-
Save EvanLovely/d508011e107e6fefe14b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Git Checkout Helper | |
gitch() { | |
git branch | |
echo "Branch to checkout? (Fuzzy searching from left to right with space support)" | |
read branch | |
branches=$(git branch | egrep -i "${branch// /.*}" | tr -d ' ') | |
count=$(echo "$branches" | egrep -c ".") | |
if [ "$count" = "1" ]; then | |
git checkout $(echo $branches | tr -d '\n' | tr -d '*') | |
elif [[ "$count" = "0" ]]; then | |
echo "No branches matched" | |
else | |
echo "Need to match a single branch. Found these:" | |
echo "$branches" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment