gitBlock 1.4: Filters and Hooks
Background: https://unsplash.com/photos/V1YEEItoOTE
pre-commit: Before commit is created âī¸prepare-commit-msg: Before commit editor openscommit-msg: After commit message is enteredpost-commit: After commit is createdpre-push: Before pushing to remote.git/hooks/ directory.git is an invisible directory that stores all the git information
.sample extension)Warning
Hooks in .git/hooks/ are not tracked by git itself!
Note
A non-zero exit code will abort the git operation
pre-commit Framework đPython tool to manage and maintain (multi-language) pre-commit hooks.
https://pre-commit.com/
pre-commit framework makes it easy:
Note
After pre-commit install, hooks run automatically on git commit
Create a .pre-commit-config.yaml file in your repository:
black (Python), styler (R), prettier (JS)ruff (Python), lintr (R)detect-secrets, bandittrailing-whitespace, check-merge-conflictmixed-line-endingTip
Use --all-files when first setting up or updating hooks
Sometimes you need to bypass hooks:
hk: New alternative tool for managing git hooksWarning
Filters can be complex, but often tools offer to set them up for you!
Any Questions?