Create git commits with prime SHA-1 hashes.
git-prime is a tool that fuzzes your commit message until it finds one that produces a prime number when the SHA-1 hash is interpreted as a 160-bit integer.
Why? Because you can. And because prime commit hashes are mathematically indivisible.
Linux/macOS:
curl -fsSL https://textonly.github.io/git-prime/install.sh | bashWindows (PowerShell):
irm https://textonly.github.io/git-prime/install.ps1 | iexManual Installation: If you prefer not to pipe URLs to bash:
- Download the scripts from this repo.
- Place them in your
$PATH. - Ensure they are executable (
chmod +x).
Instead of git commit, use:
git prime-commit "Your commit message"
# or
git prime-commit -m "Your commit message"The tool will:
- Create a commit object.
- Check if the hash is prime.
- If not, append a
Prime-Nonce: Ntrailer to the message and try again. - Repeat until a prime hash is found.
You can make the search harder by adding prefixes or difficulty requirements. The result is always guaranteed to be prime, regardless of other flags.
Proof of Work (Leading Zeros): Find a prime hash that starts with 3 zeros.
git prime-commit "Initial commit" --difficulty 3Hex Vanity Prefix:
Find a prime hash starting with dead...
git prime-commit "Fix bug" --hex-prefix deadDecimal Prefix:
Find a prime hash where the integer value starts with 123...
git prime-commit "Refactor" --prefix 123Timeout: Stop after 60 seconds if no prime is found (the default searches forever).
git prime-commit "WIP" --timeout 60Check which of your commits are mathematically pure using the custom log viewer:
git prime-log- SHA-1 hashes are 160 bits (40 hex characters).
- Interpreted as integers, they range from 0 to ~$10^{48}$.
- Miller-Rabin primality test checks if the hash is prime (probabilistic, 40 rounds).
- Message fuzzing appends a Git trailer (
Prime-Nonce: 1,Prime-Nonce: 2, etc.) to find different hashes without changing the commit body significantly.
Performance: Typical runtime is 30–120 seconds. The tool uses fast string matching for prefixes/difficulty first, then runs the computationally expensive primality test only on candidates that match the structure.
SHA-1 hashes are 160-bit integers. By the Prime Number Theorem, the density of primes near
However, standard git commits are randomly distributed. git-prime forces the universe to align by incrementing a nonce until a prime is found.
We live in a chaotic universe. Most data is composite, divisible, breakable. A prime number is atomic; it cannot be divided.
By ensuring your commit hash is prime, you are creating an immutable, indivisible anchor in the history of your project. You are not just pushing code; you are claiming a unique coordinate in number theory space that can never be factored.
Does this weaken the repository security?
Technically, yes. Practically, no.
Restricting hashes to prime numbers reduces the search space by a factor of ~111. In information theoretic terms, this reduces the entropy by
- Standard SHA-1: 160 bits of entropy.
- Prime SHA-1: ~153.2 bits of entropy.
While SHA-1 has known collision vulnerabilities (SHAttered), losing 7 bits of entropy to primality constraints does not meaningfully increase the risk of accidental collisions in any universe we currently inhabit.
MIT