Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created May 25, 2011 14:40
Show Gist options
  • Save jcromartie/991095 to your computer and use it in GitHub Desktop.
Save jcromartie/991095 to your computer and use it in GitHub Desktop.
Git pre-commit hook to help stay up-to-date with master
#!/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