From 5a1408d62aa4a4c4902310006e2a715b0e1e50be Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 10 Sep 2026 16:04:18 +0000 Subject: [PATCH] chore(repo): ignore `.worktrees/` so an agent worktree inside the checkout is not untracked MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `.gitignore:129` carried `.claude/worktrees/` and nothing else, so a linked worktree created at `/.worktrees/NAME` — one of five registered worktrees in a live container chose that path — showed up as `?? .worktrees/`. A stop hook that asks for untracked files to be committed then points at the one kind of path that must never be committed: the directory holds a `.git` FILE whose content is `gitdir: /abs/path/.git/worktrees/NAME`, an absolute pointer into one container's administrative state, plus a whole second checkout of the repository. Measured in a dedicated worktree, before and after: git worktree add .worktrees/scratch HEAD git status --porcelain before: `?? .worktrees/` after: clean git check-ignore -v .worktrees before: exit 1 (no match) after: exit 0, `.gitignore:131:.worktrees/` The entry is the exact directory name, dot-prefixed and directory-only, in the same unanchored form as its neighbour `.codex/`. It matches `.worktrees/` at any depth and nothing else: `worktrees/`, `my-worktrees/`, `.worktrees-backup/` and `docs/worktrees/` all still read as not ignored. Claude-Session: https://claude.ai/code/session_01YKEjmbYNvYWJvWGSWx26zK Co-authored-by: Claude --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 694c9dc679..9023b5fbe6 100644 --- a/.gitignore +++ b/.gitignore @@ -126,4 +126,6 @@ examples/app-crm/storage/ # Local agent tooling .codex/ -.claude/worktrees/ \ No newline at end of file +.claude/worktrees/ +# an agent worktree is git plumbing, never repo content: a `.git` FILE reading `gitdir:` plus a whole second checkout +.worktrees/