Created
February 21, 2011 13:47
-
-
Save nightscape/837074 to your computer and use it in GitHub Desktop.
Server side Git update hook which rejects pushes without prior pulls from master
This file contains hidden or 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
refname="$1" | |
oldrev="$2" | |
newrev="$3" | |
# Find out revision of master | |
masterref=`git show-ref --hash --heads master` | |
# Find out common merge base of master and the checked in revision. | |
mergebase=`git merge-base $masterref $newrev` | |
if [[ $mergebase != $masterref && ( $refname == *development* || $refname == *feature* ) ]] | |
then | |
echo "Cannot push changes. Merge base is $mergebase, master is $masterref. Please type 'git pull origin master' and merge any conflicts first before$ | |
exit 1; | |
else | |
exit 0; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment