Last active
June 24, 2017 15:40
-
-
Save nkvenom/348c5c3ccb198b77cd621b085ffcf96d to your computer and use it in GitHub Desktop.
A function to quckly jump branches only passing the ticket number or a substring
This file contains 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
# Quickly change branches | |
function jto() { | |
local nmatches=$(git branch | grep -i $1 | wc -l) | |
local branches=$(git branch | grep -i $1 | grep -oE '[[:alpha:]0-9/-]+') | |
if (( $nmatches > 1 )); then | |
echo 'Found branches' | |
printf "$branches\n" | |
else | |
echo Checking out $branches | |
git checkout $branches | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment