Skip to content

Instantly share code, notes, and snippets.

@mijdavis2
Forked from jcromartie/pre-commit
Last active June 2, 2021 21:18
Show Gist options
  • Select an option

  • Save mijdavis2/09b6ff4e082faa3e3416d3e663084dd7 to your computer and use it in GitHub Desktop.

Select an option

Save mijdavis2/09b6ff4e082faa3e3416d3e663084dd7 to your computer and use it in GitHub Desktop.
Git pre-commit hook to help stay up-to-date with master
#!/bin/sh
# 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... it looks like this branch is out of date"
echo "please merge from master and try again"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment