Skip to content
pre-commit hook for Git that checks for suspicious files.
Python Shell Makefile
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
Makefile
README.md
git-deny-patterns.json
install-for-project.sh
safe-commit-hook.py

README.md

Safe Commit Hook

This is a git pre-commit hook that is inspired by the Gitrob project.

It adds an automatic check to prevent developers from checking in suspicious files (as defined by Gitrob's signatures.json)

Installation

git clone https://github.com/jandre/safe-commit-hook.git 
cd safe-commit-hook
make install  

This will do the following:

  • Create a ~/.safe-commit-hook directory and copy the files from this repo there.
  • Create a git alias so you can do git init-safe-commit in a project directory, which will create .git/hooks/pre-commit (WARNING: will blow away any other pre-commit hooks).

Now you will get an error if you try to do anything fishy!

asciicast

Editing the rules

They are currently in JSON format at ~/.safe-commit-hook/git-deny-patterns.json.

Just remove the rules you wish to ignore. In the future, would nice to have a .git-safe-commit-ignore file for a repo.

TODO

  • Allow project specific exceptions for safe commit checks.
  • Don't blow away any other git pre-commit hooks in git init-safe-commit.
  • Extend the JSON spec to allow for searching for body of modified files.
You can’t perform that action at this time.