Created
May 25, 2011 14:40
-
-
Save jcromartie/991095 to your computer and use it in GitHub Desktop.
Git pre-commit hook to help stay up-to-date with 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
#!/usr/bin/env bash | |
# hook to enforce that current branch is up-to-date with latest | |
# changes from master before committing | |
# put me in .git/hooks and make me executable | |
# the output of rev-list in the following test will be empty if there | |
# are no commits in master that aren't in the current branch | |
if [ ! -z "$(git rev-list ..master)" ] | |
then | |
echo "abandoning commit" | |
echo "please merge from master and try again" | |
echo " git merge master" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment