Git Some Hooks

Jan 2019 update : There are probably many better ways to do this, I consider this a failed experiment. I plan on repeating this failed experiment at somepoint but using golang instead.

Well, I fell a bit behind on my promise to post at least something weekly.

So here’s a post on git-precommit hooks and how to use them to enforce code quality.

The premise is that enforcing code quality should be automatic.

The git repository at should be self explanatory, but here’s a brief rundown from the


Git hooks for formatting python, java, and golang files.


git clone

cd git-hooks; python

The installation creates ~/.git_template/hooks/pre-commit and sets the git global init.templatedir to ~/.git_template. New and cloned git repositories will pick up the pre-commit hook.

On a git commit, the script executes each hook in the hooks directory. Modify, remove, or add new python scripts in this directory and they will be picked up the next time the pre-commit hook runs.


168 Words

2016-07-22 21:12 -0500