Add .claude/worktrees/ to Agents.gitignore - #4895
Open
QuentinDE33 wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/-wflag, by subagents declaringisolation: 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 statusin 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 Codesection inGlobal/Agents.gitignoredoesn't already cover this:.claude/*.local.jsonmatches only top-level.local.jsonfiles, and.claude/**/*.logmatches 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 Codesection, with no duplicate rule.Links to documentation supporting these rule changes
.claude/worktrees/<name>/at your repository root", followed by the explicit tip: "Add.claude/worktrees/to your.gitignoreso worktree contents don't appear as untracked files in your main checkout."isolation: worktreeget their own worktree in the same location.Merge and Approval Steps