[FEATURE] Change default worktree dir to `.git/tmp`
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
When using claude --worktree, the repo is placed in .git/worktrees. When finished with the work there, I merge those changes into the parent repo and close the worktree.
However, if you run git add . in the parent before the worktree is removed, git will add it as a sub repo, with all of the problems that carries with it.
Proposed Solution
Put the worktree folders in .git/tmp. git will ignore the child repo folder when performing operations on the parent.
This is how Git Subrepo operates, for a live example.
Alternative Solutions
Related to https://github.com/anthropics/claude-code/issues/27282. If worktree paths were configurable, I'd configure .git/tmp.
Priority
Low - Nice to have
Feature Category
CLI commands and flags
Use Case Example
claude -w some-featureclaude -w some-other-feature- Do some work in those folders that creates conflicts
- Merge
some-featureback into the parent repo, then delete the worktree - Merge of
some-other-featurefails because of conflicts. Resolve them. - Run
git add .to wrap up merge. some-other-featurerepo folder gets added as a sub repo...
If some-other-feature were in .git/tmp/some-other-feature, it would not be added.
Not a show-stopper, but I've accidentally added the worktree folder more than once.
Additional Context
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗