Git Police
Git Police is a commit-time assistant designed to prevent low-quality or AI-slop code from being pushed. It challenges you with a senior-developer style question about your changes and only allows the commit when you demonstrate understanding of the code.
It supports both local models via Ollama and remote evaluation using Gemini.
Installation
Install inside your virtual environment
pip install git-police
Initialization
Run once inside a git repository
git-police init
This sets up the Git hook that triggers the code-understanding check before each commit.
To run global mode (Gemini only)
- Export your
GEMINI_API_KEY
export GEMINI_API_KEY="your_api_key"
- Run a commit with global mode enabled
GIT_POLICE_MODE=global git commit -m "msg"
To run a different Ollama model
By default, Git Police uses phi4-mini:latest. To use a different local model:
- Ensure you have ollama in your system
- pull the model you want to use
- Commit using the model
You can either use
GIT_POLICE_MODEL="your_model" git commit -m "msg"
To use the model
Or set it up once
export GIT_POLICE_MODEL="your_model"
and now you can commit as normal and it will use your specified model
Adjusting Maximum Characters Sent to the Local Model
If you want faster responses from your local model, you can reduce the number of characters sent:
MAX_CHAR=5000 GIT_POLICE_MODEL="your_model" git commit -m "msg"
Adjust MAX_CHAR as needed
Bypassing the Check (Emergency Commits)
If you encounter hallucinations or need to bypass Git Police temporarily:
git commit -m "your msg" --no-verify
Example
See git-police in action
Metadata
Release files for git-police 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| git_police-0.1.6.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| git_police-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / git_police-0.1.6.tar.gz
| Download URL | git_police-0.1.6.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24fbc58131b3c50881ad930c8688707dc7cfd511823fc1f88ba7428c28fbb41d
|
|
BLAKE2b-256 checksum How to use checksums |
d24683af3cc82bcb3c0aaef9454d49e3a1b5458385d79806eadb4971d2d9442a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / git_police-0.1.6-py3-none-any.whl
| Download URL | git_police-0.1.6-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ef45ccb17fabde47ddde85150655e01cf17916b1e78693421f208d2ad34f9db3
|
|
BLAKE2b-256 checksum How to use checksums |
9ff43aae003084865262ea4235c3d5cbdb3eb0e8a2ac77339c6bbc0f8b225aca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.10 {"installer":{"name":"uv","version":"0.9.10"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|