Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # git checkout branch with simple search
- # eg.
- # g some-branch
- # > git checkout some-branch-with-a-long-name
- if [ -z $1 ]; then
- echo "Usage: g <branch-name>"
- exit 1
- fi
- first_match=$(git branch | grep $1 | head -1)
- if [ -z $first_match ]; then
- echo "No branches match $1, soz."
- exit 1
- fi
- echo "git checkout $first_match"
- git checkout $first_match
- exit 0
Add Comment
Please, Sign In to add comment