Skip to content

Instantly share code, notes, and snippets.

@chandeeland
Last active June 23, 2022 15:17
Show Gist options
  • Save chandeeland/bea44e482887bb496f1c26b0cd412b77 to your computer and use it in GitHub Desktop.
Save chandeeland/bea44e482887bb496f1c26b0cd412b77 to your computer and use it in GitHub Desktop.
a little bash toy to help find branches easier
#!/bin/bash
GIT=`which git`
FOUND=`$GIT branch | grep $1 | sed -e 's/^[ *] //' | sed -e 's/remotes\/origin\///g' |sort -u`
NUM_FOUND=`echo $FOUND|wc -l`
echo
if [ $NUM_FOUND -gt 1 ]; then
echo 'FOUND THESE MATCHING BRANCHES'
echo
echo "$FOUND"
elif [ $NUM_FOUND -eq 1 ]; then
echo 'you got it'
git checkout $FOUND
else
echo 'NOT FOUND'
fi
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment