Skip to content

Instantly share code, notes, and snippets.

@g-i-o-
Last active May 6, 2016 13:53
Show Gist options
  • Save g-i-o-/94a467a095a371de1b398f507ff6cc1d to your computer and use it in GitHub Desktop.
Save g-i-o-/94a467a095a371de1b398f507ff6cc1d to your computer and use it in GitHub Desktop.
git-on :: for performing stuff on ther branches without all the (manual) switcharoo.
#!/bin/bash
if [ "$2" != "do" ]; then
echo "Runs a git command on the given branch and returns to this one."
echo "Usage:"
echo " git on [branch] do [normal git command] [arg1] ..."
exit
fi
tbranch="$1"
shift
shift
cbranch=`git rev-parse --abbrev-ref HEAD`
echo "git checkout $tbranch"
git checkout $tbranch
echo "git $@"
git $@
echo "git checkout $cbranch"
git checkout $cbranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment