Brute-Forcing Joy: How to Engineer Memorable Git Commit Hashes
Share this article
For developers, Git commit hashes are typically meaningless hexadecimal strings—cryptic identifiers like 68ec0dd or c0ffeeee. But what if you could transform these into memorable inside jokes? Tyler Cipriani's recent exploration reveals how to brute-force Git commits to create hashes that spark joy, all while maintaining repository integrity.
The Hexadecimal Palette
Git uses SHA-1 or SHA-256 hashes (40- or 64-character hex strings), limiting "spellable" words to letters A-F and numbers 0-9. Clever substitutions expand possibilities:
- 0 → O
- 1 → l
- 5 → s
This allows creations like dadb0d (dad bod), bada55 (bad ass), or 0ddba11 (oddball).
How Git Commit Hashing Works
A Git commit object is a compressed file containing:
commit [size]\0tree [hash]
author [details]
committer [details]
[message]
The hash is generated from this entire structure. As Cipriani demonstrates, you can recompute it manually:
git cat-file -p HEAD > commit-msg
COMMIT_SIZE=$(wc -c < commit-msg)
printf 'commit %d\0' "$COMMIT_SIZE" | cat - commit-msg | sha1sum
Naive Brute-Forcing (and Why It Fails)
Appending invisible whitespace (spaces/tabs) alters the hash. A simple Bash script can hunt for specific prefixes:
while [[ ! "$CURRENT_HASH" =~ ^00 ]]; do
grep -o . <<< "$SPACE_CHARS" | shuf -n1 >> commit-msg
CURRENT_HASH=$(CALC_HASH)
done
But this is wildly inefficient—finding 00000 took 2 hours.
Optimized Tooling: Enter lucky_commit
The open-source tool lucky_commit revolutionizes the process:
1. Pre-computes hash states before variable padding
2. Parallelizes hashing across CPU threads (or GPUs)
3. Achieves 00000 in 0.1 seconds vs. hours
"By pre-computing the hash state before appending padding,
lucky_commitdoes a fraction of the bit twiddling." — Cipriani
Automating Whimsy with Git Hooks
Integrate this into daily workflow via a post-commit hook:
WORDS=(bada55 0ddba11 c0ffee)
lucky_commit "${WORDS[RANDOM%${#WORDS[*]}]}"
Result: Every commit gets a playful hash like ✨ bada55 ✨ without altering visible metadata.
Why This Matters
Beyond humor, this demonstrates:
1. SHA-1's malleability: Padding changes enable targeted collisions (though harmless here)
2. Git internals mastery: Understanding object structure unlocks creative control
3. Developer ergonomics: Small joys improve toolchain morale
As Cipriani notes: "In bending version control to their whims, developers reaffirm mastery over their tools."
Source: Subliminal Git Commits by Tyler Cipriani