Tips for using a git pre-commit hook | git | codeinthehole.com by David Winterbottom
Keep your hook script in source control
Commit your hook script (say pre-commit.sh) at the root of your project and include the installation instructions in your README/documentation to encourage all developers use it.
Installation is nothing more than:
ln -s ../../pre-commit.sh .git/hooks/pre-commit
Then everyone benefits from running the same set of tests before committing and updates are picked up automatically.
Stash unstaged changes before running tests
Ensure that code that isn't part of the prospective commit isn't tested within your pre-commit script. This is missed by many sample pre-commit scripts but is easily acheived with git stash:
Read full article from Tips for using a git pre-commit hook | git | codeinthehole.com by David Winterbottom
No comments:
Post a Comment