Dokumentationerreichbar
Anthropic, Run parallel sessions with worktrees
code.claude.com (externe Seite)
Die Herstellerdokumentation zu getrennten Worktrees: ein zweites Arbeitsverzeichnis mit eigenen Dateien und eigenem Branch auf derselben Historie. Sie belegt die Antwort auf die Frage, wie zwei Agenten gleichzeitig an einem Projekt arbeiten können, ohne sich in die Quere zu kommen, und nennt die Kanten: Ein frischer Auscheckvorgang hat die nicht committeten Dateien nicht dabei, und aufgeräumt wird nur, was keine Arbeit mehr enthält. Für die Mitnahmeliste steht das Beispiel des Herstellers selbst da, und es besteht aus zwei Umgebungsdateien und einer Datei mit Zugangsdaten. Ein neuer Worktree zweigt in der Voreinstellung vom Standardzweig auf dem Server ab, ein Schalter stellt ihn auf den lokalen Stand um.
geprüft 10.11.2026
Worauf sich diese Seite beruft, wörtlich, abgerufen am 08.10.2026:
Running each Claude Code session in its own worktree gives it a separate copy of the files to edit, so one session can build a feature while a second fixes a bug.
bestätigt 10.11.2026Only files that match a pattern and are also gitignored are copied, so tracked files are never duplicated.
bestätigt 10.11.2026This .worktreeinclude copies two env files and a secrets config into each new worktree
bestätigt 10.11.2026None of them tracks which files a shell command writes
bestätigt 10.11.2026The same enforcement covers every subagent Claude spawns from the isolated session.
bestätigt 10.11.2026Claude sees each refusal as a tool error that names the worktree and says how to proceed.
bestätigt 10.11.2026Non-interactive runs with -p have no exit prompt, so Claude doesn't clean up their worktrees
bestätigt 10.11.2026so that concurrent cleanup can't remove it, and releases the lock when the agent finishes
bestätigt 10.11.2026If a worktree with the name you pass to --worktree already exists, Claude Code opens it instead of creating a new one.
bestätigt 10.11.2026a worktree that Claude Code creates contains LFS pointer files instead of the real files
bestätigt 10.11.2026A worktree gets its own files and branch, but it shares the following with the main checkout
bestätigt 10.11.2026Once the key is on, Claude Code removes both worktree tools or refuses calls to them.
bestätigt 10.11.2026The errors belongs to a different repository and is a leftover worktree both mean git ties the directory for the worktree name you passed to another location.
bestätigt 10.11.2026