Skip to content

Instantly share code, notes, and snippets.

@nkvenom
Last active June 24, 2017 15:40
Show Gist options
  • Save nkvenom/348c5c3ccb198b77cd621b085ffcf96d to your computer and use it in GitHub Desktop.
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
# 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