Skip to content

Add .claude/worktrees/ to Agents.gitignore - #4895

Open
QuentinDE33 wants to merge 1 commit into
github:mainfrom
QuentinDE33:add-claude-worktrees-to-agents-gitignore
Open

Add .claude/worktrees/ to Agents.gitignore#4895
QuentinDE33 wants to merge 1 commit into
github:mainfrom
QuentinDE33:add-claude-worktrees-to-agents-gitignore

Conversation

@QuentinDE33

Copy link
Copy Markdown

Link to the application or project's homepage

https://claude.com/claude-code

Reasons for making this change

Claude Code (Anthropic's CLI coding agent) creates git worktrees under .claude/worktrees/<name>/ at the repository root. This isn't an opt-in corner of the tool: worktrees are created by the --worktree/-w flag, by subagents declaring isolation: worktree, and automatically for every new session in the Claude desktop app.

Because a worktree is a full second checkout of the repository, leaving the path untracked is the noisiest possible case — git status in the main checkout reports the entire worktree tree as untracked files. The directory is generated, machine-local, and never meant to be committed, so the rule applies to everyone using Claude Code rather than to any particular team or workflow. Anthropic's documentation says so directly (quoted below).

The existing # Claude Code section in Global/Agents.gitignore doesn't already cover this: .claude/*.local.json matches only top-level .local.json files, and .claude/**/*.log matches only log files. The commented-out # .claude/ is not a substitute either — it's commented precisely because .claude/settings.json, .claude/commands/, .claude/agents/, and .claude/skills/ are commonly committed and shared with a team, which is the distinction this template already draws.

Scope is one line, in the existing # Claude Code section, with no duplicate rule.

Links to documentation supporting these rule changes

Merge and Approval Steps

Claude Code creates git worktrees under .claude/worktrees/ at the repository
root. The official documentation explicitly recommends gitignoring this path
so worktree contents don't appear as untracked files in the main checkout.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@QuentinDE33
QuentinDE33 requested a review from a team as a code owner August 10, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant