How Git AI Works
Learn how Git AI builds an accurate git blame for AI-generated code.
Git AI is an open-source git extension that builds accurate AI-attribution on top of Git, so you know exactly which lines were written by each agent session. Once attribution is tied to the line, a few things become possible:
- Measure the real ROI of coding agents. See what actually lands in production — not how much code agents generated, but how much of it survives review, ships, and holds up over time. Attribution makes the durability and reliability of AI-written code something you can measure instead of guess at.
- Engineer your harness with a feedback loop. When you can see which sessions, models, and prompts produced code that stuck versus code that got rewritten, you can tune your agent setup against real outcomes.
- Maintain large AI-codebases. Each line stays linked to the session that wrote it, so humans and agents alike can pull up the full context behind any change — the prompt, the model, the reasoning — long after the session ends.
How it works
Git AI has three parts: a working log that records attribution intra-commit as agents edit, attribution notes that tie each line in a commit back to the agent session and tool call that generated it, and fast attribution diffing/merging on every rebase, squash, stash/pop, cherry-pick, and reset so attribution is never lost.
1. Agents checkpoint as they work
Git AI registers a pre/post tool-calls for every supported agent. After each Edit, Write, or Bash tool call, the hook runs git ai checkpoint to mark the lines just written as AI-authored.
Checkpoints are diffs between the current state and the previous checkpoint, each marked AI- or human-authored. They live in .git/ai until you commit. When you edit the files yourself between agent runs, those lines are checkpointed as human-authored, so hand-written and AI-written code stay cleanly separated.
Git AI runs outside the hot path. It does not rely on git hooks or wrap the git binary, so there is 0 overhead to your git commands.
2. Attribution attaches on commit
When you commit, Git AI consolidates those checkpoints into an authorship log and attaches it to the new commit as a git note in refs/notes/ai. Your history and commit messages stay clean — the attribution rides alongside.
The note maps each file to the agent sessions that authored it and their line ranges, followed by JSON metadata for each session (agent, model, human author, and a messages_url pointing to the full session). View it with:
git log --show-notes=aiNotes (ai):
src/auth.ts
session_1 1-8,10-21
session_2 9,22-30
src/db.ts
session_1 12-193. Attribution survives every git operation
Notes are addressed by commit SHA, so any operation that creates new commits would normally leave attribution behind. Git AI understands each git operation and rewrites the notes to match — eventually consistent, typically within 5–100ms of the operation completing.
This covers rebase, merge, merge --squash, cherry-pick, revert, commit --amend, reset, stash/pop, checkout/switch, and pull/push/fetch. For the full support matrix — including the known gaps (git mv, filter-branch, git replace) and web-UI merges — see the capabilities table in the README.
Attribution storage
By default, attribution lives in git notes under refs/notes/ai:
- Zero infrastructure — the notes live in your repo alongside the objects they describe.
- Travels with the code — notes sync over
git pushandgit fetch, so attribution reaches the remote the same way commits do. - Tightly scoped — Git AI only ever touches the
refs/notes/airef.
When hundreds of developers write notes to the same refs, there can be contention on the notes refs. We suggest starting out with git notes, and moving to the hosted notes store in the Git AI Platform when you scale.
Design choices
- No workflow changes — just prompt and commit. Git AI tracks AI code accurately without cluttering your git history.
- "Detecting" AI code is an anti-pattern — no heuristics. Agents explicitly mark the hunks they wrote, giving the most accurate attribution possible.
- Local-first — works 100% offline, no login required. No filewatchers or keyloggers.
- git-native open standard — built on git notes so you're never tied to a single vendor. The ecosystem is multi-agent, and agents are the new IDEs.
- Sessions stay out of git — notes link to agent sessions stored locally, in the Git AI Cloud, or in a self-hosted store.
Distribution
Git AI installs on every developer endpoint, including via MDM. It staples attribution onto every commit with no per-repo hooks or configuration — install once and every repository is tracked automatically.