October 20, 2021    Share on: Twitter | Facebook | HackerNews | Reddit

Git hooks

Git hook makes easier to keep order in the software project: - can help following agreed conventions related with e.g. + code format, code quality + workflow + commit practices and format

Exemplary check before the commit

If not exists, create hooks directory in the .git folder of the demo and add these files.

├── isort_hooks.py
└── pre-commit


#!/usr/bin/env python
import sys

from isort.hooks import git_hook

sys.exit(git_hook(strict=True, modify=True))


set -e  # stop script execution when error encoutered

# Run flake8 check
flake8 .

# Sort imports with isort
python ./.githooks/isort_hooks.py


There is tool pre-commit that ease installation and configuration of git hooks. Read my note on that: Pre-commit hooks

References: - Git Hooks - user friendly description, tons of examples, reference links - Git Book on hooks -

See also: