Last active
August 23, 2019 03:36
-
-
Save GenevieveBuckley/d8f20191087d0848645f158d63d0197f to your computer and use it in GitHub Desktop.
Git pre-commit hooks with black and flake8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
repos: | |
- repo: https://github.com/ambv/black | |
rev: stable | |
hooks: | |
- id: black | |
language_version: python3.7 | |
- repo: https://github.com/pre-commit/pre-commit-hooks | |
rev: v1.2.3 | |
hooks: | |
- id: flake8 | |
- id: check-ast | |
- id: check-merge-conflict | |
- id: no-commit-to-branch --branch master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use git pre-commit hooks
Make sure you have black, flake8, and pre-commit installed into your environment.
Then create
.pre-commit-config.yaml
in the root directory of your repository and run:This will put all your pre-commit hooks into
.git/hooks/
and make sure they are enforced before every commit.Further reading
https://ljvmiranda921.github.io/notebook/2018/06/21/precommits-using-black-and-flake8/