Field NotesNovember 2026
Path filters are blind inside .git: deleted files and dropped branches are still in the directory you hand to an AI tool
A repository directory is a compressed, hash-addressed database of every state Git still remembers. Controls that decide by path or by raw bytes have nothing to match inside it. In our lab, a path deny list matched none of the 34 files under .git, and a byte scan saw none of the canaries that were recoverable from objects.
In this piece
- 01One directory, several points in time
- 02Where old content lives after each everyday action
- 03The lab: five exports, four canaries
- 04What eight tools' documentation says about .git
- 05Recorded gaps: tools that read more than their ignore rules implied
- 06What the secrets research measured, and what it did not
- 07Three questions before a tool gets a directory
- 08What to do on Monday morning
When a developer says "I deleted that key", three things are usually true: the file is gone from the working directory, new commits do not contain it, and .gitignore now covers it. None of the three touches the object store. Git is a content-addressed key-value store: objects are named by hash, and a blob holds content without a file name1. While a commit or a reflog entry still points at the old content, or garbage collection has not reached it, it is still in .git.
That matters once you hand the directory to an AI coding tool. The tool gets everything its process can read. The controls that decide what may be read or sent look at paths (ignore files, deny lists) or at raw file bytes (string and pattern matching). Inside the object store, file names are hashes and content is zlib-compressed, sometimes stored only as a delta against another object12. Neither kind of control has anything to match.
Our claim: when a tool gets a directory, the unit of exposure is the object store, and most tools' documentation does not say what they do with it.
01One directory, several points in time#
Your editor shows the working tree. Everything else is under .git, or wherever .git points.
The object store has no paths#
A new object is first written as a loose file under .git/objects, in a subdirectory named after the first two characters of its hash; later Git packs objects into objects/pack12. In a pack, an object can be stored as a delta: instructions that copy byte ranges from a base object and insert new data2. File names live in tree objects; a blob has no name1.
So a repository with years of history can be a few pack-<hash>.pack files. An old customers.sql has no path of its own: its name is in a tree, its content in a blob, and both are compressed inside a pack.
What keeps old content alive#
An object stays while something reaches it. git gc keeps what is reachable from branches, tags, the index, remote-tracking branches, reflogs and everything under refs/13.
- reflog
.git/logs: where each ref has pointed, on this machine only1412. It still points at commits from before an amend or a rebase13.- stash
- The newest entry is
refs/stash; older ones exist only in its reflog. Each is a commit, andgit stash -aalso stores ignored files15. - index
.git/index. The manual names earlier runs ofgit addas a source of unreachable objects13.- cruft pack
- Where
git gcputs unreachable objects by default (gc.cruftPacksistrue)13. - linked worktree
- Its
.gitis a file with agitdir:path; objects and refs belong to the main repository1216. - alternates
objects/info/alternateslists other object stores that this repository borrows from12.
The last two mean that .git can extend beyond the directory you hand over.
02Where old content lives after each everyday action#
Two things decide how long content stays: whether anything points at it, and whether collection runs. Two clocks apply. A reflog entry expires by the date recorded in the entry14; when we checked, the commit's own date played no part. An object that nothing points at then gets a grace period (gc.pruneExpire, two weeks), counted from the object's modification time, which Git refreshes when the object is written again13. A cruft pack records that time for each object2. Automatic collection starts only above about 6,700 loose objects (gc.auto) or 50 packs (gc.autoPackLimit), so a small repository may not collect for a long time13. The periods below are the manual's defaults.
| Action | Where the content still is | Default period | What removes it |
|---|---|---|---|
| Delete a file and commit | In earlier commits: reachable history that every clone receives3 | None | A history rewrite; clones and forks elsewhere remain17 |
Add it to .gitignore | No effect on tracked files; git rm --cached changes later commits only4 | None | As above |
| Delete a branch | The branch reflog goes with it18, but the HEAD reflog still points at commits you made or checked out there5 | Reflog entries: 30 days from their own date (gc.reflogExpireUnreachable). Objects: two weeks of modification time | git gc, once both have passed |
git stash drop | Unreachable at once, still in the object store15. A stash you keep never expires by default19 | Two weeks of modification time, not from the drop | git gc after the grace period |
| Amend, rebase, force-push | Locally, the reflog13. A bare remote keeps no reflog by default; the old commit stays until that server collects20 | Local: as for a deleted branch. Remote: the platform's | Locally git gc; remotely the platform17 |
git gc with defaults | Keeps what refs and reflogs reach. Unreachable objects inside the grace period go into a cruft pack; older ones are deleted13 | Not applicable | Nothing inside the grace period |
No row says "gone immediately", and none is an exact lifetime: the two periods overlap, and nothing goes until git gc runs. When we checked, a dropped stash whose object files were 20 days old went at the next git gc, and a commit whose reflog entries had expired stayed, because a repack had refreshed its modification time.
The lab in the next section has a second run with commit and reflog dates and object file times set 45 days back before the same default git gc: the deleted branch and the dropped stash are gone, 14 of 23 objects remain, and the deleted file is still in reachable history5. That run rewrites dates and file times; nobody waited 45 days.
03The lab: five exports, four canaries#
We built a synthetic repository, planted four canary strings in states a developer would call "dealt with", ran one default git gc, and exported the project in five ways5.
The two measurements are these functions.
def scan_objects(repo: Path) -> set[str]:
"""Canaries recoverable from every object Git can still enumerate."""
found: set[str] = set()
listing = git(repo, "cat-file", "--batch-all-objects", "--batch-check", check=False)
for line in listing.splitlines():
sha, kind, _size = line.split()
if kind != "blob":
continue
data = subprocess.run(["git", "-C", str(repo), "cat-file", "blob", sha], env=ENV, capture_output=True).stdout
for name, (token, _why) in CANARIES.items():
if token.encode() in data:
found.add(name)
return found
def scan_files(root: Path, skip_git: bool = True) -> set[str]:
"""Canaries visible as plain bytes in files (what a string scanner sees)."""
found: set[str] = set()
for p in root.rglob("*"):
if not p.is_file() or (skip_git and ".git" in p.relative_to(root).parts):
continue
data = p.read_bytes()
for name, (token, _why) in CANARIES.items():
if token.encode() in data:
found.add(name)
return found| Export | Files | Bytes | Recoverable canaries | Seen by byte scan |
|---|---|---|---|---|
Copy the working tree, skip .git | 6 | 5,790 | B | B |
git archive HEAD | 5 | 5,756 | none | none |
git bundle --all, then clone | 33 | 36,158 | A | none |
| Copy the whole directory | 40 | 40,741 | A, B, C, D | B |
| Copy the directory, then apply a path deny list | 38 | 40,688 | A, C, D | none |
Three findings#
- "Delete and ignore" leaves content in reachable history. A is in the third export, which holds only what refs reach: what any collaborator's clone receives. A byte scan of that clone does not see it.
- A deleted branch and a dropped stash cannot be cloned but are still in the directory. Of 23 objects, 9 are unreachable from any ref. The
HEADreflog holds 4 of them (the branch); nothing points at the other 5 (the stash). After gc, all 23 sit in two packs. - The deny list (
*.env,*.sql,*.pem,*.key,id_rsa*) matched none of the 34 files under.git. It dropped two working-tree files, one of them a harmless example. The filtered copy still yields A, C and D, and a byte scan of it finds nothing.
We think a longer deny list cannot fix the third finding: the only paths in the object store look like pack-<hash>.pack. A check that finds A, C and D must decode every object, unreachable ones included. A filter that reads only paths or raw bytes and still finds them would prove us wrong.
What the lab does not show#
- One Git version, default settings, 23 objects.
- Plain-text canaries only; no binary keys or other content that compresses poorly.
- C and D survive the main run because gc ran right after the repository was built; the 45-day run described above is the other end, and it is a simulation.
- Commits are dated on the day of the run, so canary results and object counts do not drift with the calendar; our re-runs matched the record. Byte counts of exports that include
.gitmove by a few bytes with the run date, and the third export's also contains the temporary path. - The deny list is ours. No real tool's filter was tested, and nothing here shows what an AI tool reads or uploads.
04What eight tools' documentation says about .git#
On 2026-11-22 we read eight tools' public documentation and recorded only what it says. "Does not say" is a finding; it means neither that the tool reads .git nor that it does not.
| Tool (page date; date read) | On .git | Ignore mechanism and its stated limits | Checkpoints |
|---|---|---|---|
| Cursor (undated; read 2026-11-22) | .git/ is in the default ignore list6 | .cursorignore and .gitignore. Terminal and MCP tools are not blocked; protection is not guaranteed6 | Local, separate from Git; mechanism not stated23 |
| GitHub Copilot (undated; VS Code page 2026-11-18; read 2026-11-22) | Not mentioned9 | Admin-set content exclusion. Not a filesystem security boundary; may miss indirect access9 | VS Code snapshots affected files before each request; location not stated24 |
| Claude Code (no visible date; page metadata 2026-11-19 to 2026-11-21; read 2026-11-22) | A protected path for writes; reads not addressed7. Worktrees share the main .git25 | .claudeignore has no effect. Read deny rules miss commands that do not name the file, and subprocesses7 | File snapshots for a session's 100 latest checkpoints, kept about 30 days26 |
| OpenAI Codex (undated; read 2026-11-22) | Read-only inside writable roots; reads not addressed8 | No ignore file on the page; an OS sandbox, network off by default8 | Not on the page |
| Gemini CLI (2026-04-10; read 2026-11-22) | Not mentioned27 | .geminiignore, for tools that support it; the page names only the @ command as an example27 | Shadow Git repository in ~/.gemini/history/<project_hash>, local, off by default28 |
| Cline (no visible date; page metadata 2026-02-15 and 2026-09-03; read 2026-11-22) | Not mentioned29 | .clineignore, marked for deprecation: not a security boundary; @ mentions and shell commands still read ignored files10 | Shadow Git repository, on by default, includes untracked files29 |
| Devin Desktop (no visible date; page metadata 2026-11-15; read 2026-11-22; Windsurf docs redirect here) | Indexing skips hidden pathnames; .git is not named11 | .devinignore covers indexing, Tab and DeepWiki; it does not block the agent's file tools11 | Not on the page |
| JetBrains AI Assistant (2026-10-12; read 2026-11-22) | Not mentioned30 | .aiignore; ignored files may still be processed in some cases30 | Not on the page |
Three observations. No page promises that .git is never read or sent: Cursor's own page exempts the terminal, and write protection in Claude Code and Codex guards against tampering, not disclosure. Checkpoints make a second copy: Gemini CLI and Cline implement checkpoints as a shadow Git repository, a second object store, and neither page says whether ignored files are excluded or when that store is collected. And one vendor's documents can disagree: Cursor's search page (undated) says its Instant Grep index is built on the machine, and that Cursor neither uploads paths or code to build a search index nor stores embeddings for search31, while its blog post of 2026-01-27 describes an indexing pipeline with embeddings that uploads every file of a new codebase32. The two may describe different features or different dates; we cannot tell, so we report both.
05Recorded gaps: tools that read more than their ignore rules implied#
In September 2026 the researcher ferstar documented that Z.ai's ZCode 3.12.3 packaged the whole workspace, complete .git included (86.6% of the payload in ferstar's sample), and tried to upload it, even with two related settings off. That 313MB archive did not upload; the server accepted a small public repository of 538 files33. Z.ai apologised and said 3.14.0 disabled the snapshot workflow34. Our SBR-2026-04 covers that case.
| Record | Identifier, date, version | What happened | Vendor response |
|---|---|---|---|
| Cursor | CVE-2025-64110 (GHSA-vhc2-fjv4-wqch), 2025-11-03, High; affected 1.7.23, patched 2.035. CVE record: CVSS 4.0 score 8.7, affected below 2.036 | After prompt injection, or with a malicious model, the agent could write a new cursorignore file that invalidated existing ones, then read protected files | The agent can no longer create or edit cursorignore files35 |
| Claude Code | The Register, 2026-01-28; version 2.1.12; no CVE that we found37 | The Register listed .env in .claudeignore, and separately in .gitignore; Claude Code still read the file. The model itself had recommended .claudeignore | Anthropic did not answer The Register's request for comment. Current documentation says .claudeignore has no effect7 |
| Claude Code | Issue #6699, 2025-08-28 to 2025-09-02; reported on 1.0.9338 | A deny rule did not stop .env from being read, the reporter said | A collaborator blamed pattern syntax; another user disputed it; the reporter confirmed the rules on 1.0.100. No fix version named |
GitHub's changelog of 2026-09-02 says the Copilot app and CLI now respect content exclusion policies39. We infer that one policy took effect on different dates on different surfaces.
The common factor is where the rule lives: inside the tool, which decides whether to pass through it. We expect more such gaps, because an agent has a terminal, and a check on the tool's own file-reading path leaves other paths open.
06What the secrets research measured, and what it did not#
28.65 million
New hardcoded secrets in public GitHub commits in 2025, up 34%. GitGuardian, 2026-03-1740
> 64%
Secrets confirmed valid in 2022 that were still valid in January 202640
17.78%
"Potential secrets" that a scan of a regular git clone misses compared with --mirror, across 52,268 repositories of the top 100 GitHub organisations by stars. Aqua Security, 2024-06-2341
40
Valid API keys found in deleted forks of 3 public repositories. Truffle Security, 2024-07-2442
Each figure measures something different. GitGuardian counts new secrets in public commits and retests old ones; its summary does not separate current files from history40. It shows that most secrets in that sample were not rotated, which is why old content keeps its value.
Aqua's figure counts unvalidated scanner findings, and the authors say the gap comes mainly from refs a regular clone does not fetch, such as refs/pull/, with deleted content only one part41. Truffle Security's studies concern hosting platforms: commits stay retrievable by hash through a fork network after the fork is deleted42, and a scan of all zero-commit force-push events in GH Archive since 2020 found, by its author's account, thousands of active secrets and earned about $25k in bounties; the post gives no exact count43.
Nobody, as far as we found, has measured the .git on developer machines: secrets in reflogs, stashes and cruft packs. Our lab shows a mechanism, not prevalence.
07Three questions before a tool gets a directory#
For each tool that will get a directory, write down three answers and their sources.
| Question | What to check | For .git |
|---|---|---|
| 1. What can the process read? | Which user it runs as, where it starts, whether it has a terminal | An agent that runs commands can run git and read any object; worktrees and alternates extend the range |
| 2. By its own documentation, what does it persist or send? | Indexes, caches, checkpoints, telemetry, model requests, each with a dated sentence | Record silence as "unknown" |
| 3. What enforces the rule? | An operating-system boundary, or the tool's own rule | A tool's rule covers only the paths the tool routes through it |
The answers to the third question fall on four rungs.
- 01
The data is absent
You hand over an export; there is no object store to read.
Unreadable - 02
Operating-system boundary
A sandbox or container limits reads and outbound connections, subprocesses included.
Enforced by the OS - 03
The tool's own rule
Ignore files, deny rules, content exclusion, each with stated exceptions.
Self-enforced - 04
Not documented
Assume it reads and stores until there is evidence.
Unknown
Check sandbox defaults too. Once enabled, Claude Code's sandbox restricts writes and outbound connections by default, but reads cover most of the machine unless you set denyRead, which does not govern the built-in Read tool44. In Codex's sandbox .git is read-only, so still readable8. This means that, for confidentiality, the documented defaults rely on blocking the network.
08What to do on Monday morning#
Take stock of what the directory still holds#
These commands are read-only.
git count-objects -vH
git rev-list --all --objects | wc -l
git cat-file --batch-all-objects --batch-check | wc -l
git fsck --unreachable --no-reflogs
git stash list
git worktree list
cat "$(git rev-parse --git-common-dir)/objects/info/alternates"
git log --all --diff-filter=D --name-only --format='%h %ad %s' --date=short
git log --all --reflog --oneline -S'string-to-find'Lines two and three compare the objects reachable from refs with everything in the store, unreachable objects and alternates included45; when we checked the lab repository, they printed 14 and 23. Line four lists what only a reflog keeps, or nothing keeps46. Line seven prints an error when the repository has no alternates. The last line has a blind spot: when we checked, it found C but not D, which no reflog points at. Any scanner that walks history from refs and reflogs shares it. To cover every object, decode each blob:
git cat-file --batch-all-objects --batch-check='%(objectname) %(objecttype)' |
awk '$2=="blob"{print $1}' |
while read -r id; do
git cat-file blob "$id" | grep -a -q 'pattern-to-find' && echo "$id"
done
git log --all --reflog --find-object=<blob-hash> --format='%h %s' --name-onlyRotate first, then remove#
Revoke or rotate a secret first. GitHub's documentation says a rewrite may then be unnecessary, and that rewritten content can remain in clones, forks, cached views and pull requests17. We infer that a tool's caches and checkpoints belong to the same class.
Content that is only in unreachable objects needs no rewrite:
git reflog expire --expire=now --all
git gc --prune=nowBoth lines are destructive. The first deletes every reflog entry, and with them older stashes, which exist only there15; when we checked, the newest stash stayed in refs/stash although git stash list printed nothing, so run git stash clear first if stashes must go too. The second collects immediately, which the manual says risks corruption if another process is writing13. The order matters: when we checked, git gc --prune=now alone left C in place.
Content in reachable history, like A, needs git filter-repo, which the Git manual recommends over git filter-branch4748. GitHub's documentation requires version 2.47 or later:
git-filter-repo --sensitive-data-removal --invert-paths --path config/settings.envThis is also destructive: it rewrites commit hashes, and a colleague's old clone can push the content back17. We did not run it.
Hand over an export, not the repository#
mkdir ../export && git archive HEAD | tar -x -C ../export
git clone --depth 1 "file://$PWD" ../export-git
git -C ../export-git remote remove origin
git fetch ../export-git main && git merge --ff-only FETCH_HEADThe first line exports one tree, without .git49; in the lab it was the only export with no canary5. Lines two and three make a separate copy one commit deep, and line four brings the agent's commits back. Three traps:
- Use
file://. From a local path, Git copies everything underobjects5047. When we checked, it printed a warning, ignored--depth, and the copy carried A, C and D. - A shallow copy can deepen itself while it can reach its source. Remove the remote, and keep the source out of the agent's reach: when we checked, the copy's reflog still named the source path.
- A linked worktree isolates edits, not history: the object store is shared1216, as Claude Code's documentation also states25. When we checked, A, C and D were readable from one.
Sandboxes, organisation controls, and guidance worth reading#
When work must happen in the original repository, use the top two rungs. Codex sandboxes commands by default, without network8. Claude Code's sandbox must be enabled, and its list of allowed domains starts empty44. The Copilot cloud agent's firewall is on by default, and GitHub says sophisticated attacks may bypass it51. Managed settings7 and organisation-level content exclusion9 make a rule consistent, we think, not stronger.
Worth reading: the Singapore CSA handbook for agentic coding assistants (v1.0, 2026-10-15), whose control M-013 blocks sensitive files unless a task needs them52; and OWASP's Secure Coding with AI cheat sheet, which warns that .gitignore affects only Git53. Neither discusses Git history or unreachable objects.