Skip to content

fix(core): add .claude/worktrees to gitignore#34693

Merged
juristr merged 5 commits intomasterfrom
fix-broken-claude-worktrees
Mar 5, 2026
Merged

fix(core): add .claude/worktrees to gitignore#34693
juristr merged 5 commits intomasterfrom
fix-broken-claude-worktrees

Conversation

@juristr
Copy link
Member

@juristr juristr commented Mar 4, 2026

Current Behavior

When Claude Code creates worktrees under .claude/worktrees/, Nx picks them up as workspace projects. This causes duplicate project errors that break the project graph.

Expected Behavior

.claude/worktrees is gitignored so worktree copies of the repo don't interfere with Nx's project detection.

Changes:

  • Add .claude/worktrees to all three gitignore templates for new workspaces
  • Add migration (22.6.1) for existing workspaces using addEntryToGitIgnore

Claude Code worktrees under .claude/worktrees/ get picked up by Nx
as workspace projects, causing duplicate project errors.

- Add .claude/worktrees to all three gitignore templates for new workspaces
- Add migration for existing workspaces (22.6.1)
@juristr juristr requested a review from a team as a code owner March 4, 2026 10:54
@juristr juristr requested a review from MaxKless March 4, 2026 10:54
@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit 77e52a3
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/69a98d29292c160008a5ee2b
😎 Deploy Preview https://deploy-preview-34693--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Mar 4, 2026

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit 77e52a3
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/69a98d29970fb9000829c362
😎 Deploy Preview https://deploy-preview-34693--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud
Copy link
Contributor

nx-cloud bot commented Mar 4, 2026

View your CI Pipeline Execution ↗ for commit 77e52a3

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 59m 59s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 3m 20s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 8s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-05 15:08:09 UTC

@juristr juristr self-assigned this Mar 4, 2026
@juristr juristr enabled auto-merge (squash) March 4, 2026 16:56
@juristr juristr disabled auto-merge March 4, 2026 16:57
@juristr juristr enabled auto-merge (squash) March 5, 2026 14:04
Comment on lines +140 to +145
"22-6-1-add-claude-worktrees-to-git-ignore": {
"cli": "nx",
"version": "22.6.0-beta.10",
"description": "Adds .claude/worktrees to .gitignore",
"implementation": "./src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migration version mismatch: The migration is named 22-6-1-add-claude-worktrees-to-git-ignore (suggesting version 22.6.1) but has "version": "22.6.0-beta.10". This inconsistency will cause the migration to run at the wrong time.

If users upgrade from 22.6.0-beta.10+ to 22.6.1, the migration won't run because Nx migrations only execute for versions newer than the user's current version. Users on 22.6.0-beta.10 or later will never get this migration applied.

Fix by aligning the version:

"22-6-1-add-claude-worktrees-to-git-ignore": {
  "cli": "nx",
  "version": "22.6.1",
  "description": "Adds .claude/worktrees to .gitignore",
  "implementation": "./src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore"
}
Suggested change
"22-6-1-add-claude-worktrees-to-git-ignore": {
"cli": "nx",
"version": "22.6.0-beta.10",
"description": "Adds .claude/worktrees to .gitignore",
"implementation": "./src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore"
},
"22-6-1-add-claude-worktrees-to-git-ignore": {
"cli": "nx",
"version": "22.6.1",
"description": "Adds .claude/worktrees to .gitignore",
"implementation": "./src/migrations/update-22-6-0/add-claude-worktrees-to-git-ignore"
},

Spotted by Graphite

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@juristr juristr merged commit bc45b92 into master Mar 5, 2026
24 checks passed
@juristr juristr deleted the fix-broken-claude-worktrees branch March 5, 2026 15:08
@github-actions
Copy link
Contributor

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants