Created
January 11, 2013 08:29
-
-
Save wederbrand/4508945 to your computer and use it in GitHub Desktop.
git post checkout hook for gerrit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BRANCH=`git symbolic-ref -q HEAD` | |
if [ "$BRANCH" == "" ]; then | |
BRANCHNAME=master | |
else | |
BRANCHNAME=`basename $BRANCH` | |
fi | |
# remote should always be origin | |
git config branch.$BRANCHNAME.remote origin | |
# set up rebase, even for local branches (since we now treat them as tracked) | |
git config branch.$BRANCHNAME.rebase true | |
# set merge to be refs/heads/master if empty | |
MERGE=`git config --get branch.$BRANCHNAME.merge` | |
if [ "$MERGE" == "" ]; then | |
git config branch.$BRANCHNAME.merge refs/heads/master | |
MERGE=refs/heads/master | |
fi | |
# set push on origin to be gerrit friendly and use the correct branch | |
PUSH=${MERGE#refs/heads/} | |
git config remote.origin.push HEAD:refs/for/$PUSH |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment