Skip to main content

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)

  1. Export your GEMINI_API_KEY
export GEMINI_API_KEY="your_api_key"
  1. 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:

  1. Ensure you have ollama in your system
  2. pull the model you want to use
  3. 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

approved

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)

Source distribution for git-police 0.1.6
File Size Uploaded
git_police-0.1.6.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for git-police 0.1.6
File Interpreter ABI Platform
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}

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page