Skip to content

Instantly share code, notes, and snippets.

@joelmccracken
Created February 27, 2014 17:29
Show Gist options
  • Save joelmccracken/9254854 to your computer and use it in GitHub Desktop.
Save joelmccracken/9254854 to your computer and use it in GitHub Desktop.
perform command on another branch
git-on-branch () {
git stash
ORIGINAL_BRANCH=`git branch | grep \* | sed 's/\*[[:space:]]//'`
git checkout $1
$2
git checkout $ORIGINAL_BRANCH
git stash pop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment