Skip to content

Instantly share code, notes, and snippets.

@amoblin
Last active May 11, 2019 09:27
Show Gist options
  • Save amoblin/d59ef96f7068b4b52a8e4833a9e5044b to your computer and use it in GitHub Desktop.
Save amoblin/d59ef96f7068b4b52a8e4833a9e5044b to your computer and use it in GitHub Desktop.
#!/bin/sh -e
# code from https://stackoverflow.com/questions/7101145/how-to-configure-specific-upstream-push-refspec-for-git-when-used-with-gerrit/7141743#7141743
if [ -z "$1" ]; then
REMOTE=origin
else
REMOTE=$1
fi
if [ -z "$2" ]; then
BRANCH=`git symbolic-ref HEAD`
case $BRANCH in
refs/heads/*)
BRANCH=`basename $BRANCH`
;;
*)
echo "I can't figure out which branch you are on."
exit 1
;;
esac
else
BRANCH=$2
fi
git push $REMOTE HEAD:refs/for/$BRANCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment