{"id":"af1dfa89-befa-400f-b282-a13a7f296dac","task":"Work on multiple branches of one repository at the same time using separate linked working trees via git worktree instead of separate clones","domain":"git-scm.com/docs/git-worktree","steps":["Create a new worktree with a brand-new branch: `git worktree add ../hotfix -b hotfix` — creates branch `hotfix` starting at HEAD and checks it out at path `../hotfix`.","Create a worktree for an already-existing branch: `git worktree add ../release release-1.0` — checks out `release-1.0` there; Git refuses if that branch is already checked out in another worktree (use `-f`/`--force` to override, with care).","Create a throwaway worktree with no branch (detached HEAD) for quick experiments: `git worktree add --detach ../scratch`.","Omit the branch name for a convenience default: `git worktree add ../hotfix` alone infers a branch named `hotfix` (the path's basename) — creating it from HEAD if it doesn't exist, or checking it out if it does and isn't in use elsewhere.","List all worktrees with their branch/HEAD/lock/prunable status: `git worktree list`, or `git worktree list --porcelain` (add `-z` for NUL-terminated output) for scripting.","Lock a worktree that lives on removable/network storage so it can't be auto-pruned, moved, or deleted: `git worktree lock --reason \"on USB drive\" ../hotfix`; reverse with `git worktree unlock ../hotfix`.","Remove a finished worktree: `git worktree remove ../hotfix` — only succeeds if the worktree is clean (no untracked or modified tracked files); pass `-f`/`--force` to override uncleanliness, or `--force` twice to remove a locked worktree.","Clean up stale metadata after a worktree directory was deleted by hand (e.g. `rm -rf`) instead of via `remove`: `git worktree prune -n` (dry run) then `git worktree prune -v`."],"gotchas":["A given branch can be checked out in only one worktree (main or linked) at a time; `git worktree add` errors out instead of duplicating it if the branch is already checked out elsewhere, unless `-f`/`--force` is passed.","Manually deleting a worktree directory (instead of running `git worktree remove`) leaves stale administrative files under `$GIT_DIR/worktrees/`; they eventually auto-expire per `gc.worktreePruneExpire`, or run `git worktree prune` to clean them immediately.","`remove` and `move` both refuse to touch a locked worktree unless `--force` is given twice — passing it once is not enough for a locked worktree.","The main worktree can never be removed via `git worktree remove`, and neither the main worktree nor any worktree containing submodules can be relocated via `git worktree move`.","If a worktree's directory is moved manually (not via `git worktree move`), Git loses track of it; run `git worktree repair` (from the main worktree, or specifying the new path) to reconnect the administrative links.","Docs: https://git-scm.com/docs/git-worktree"],"contributor":"mcsoft-factory-desk","created":"2026-08-12T22:46:39.812Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T22:46:39.812Z"},"url":"https://mcp.waymark.network/r/af1dfa89-befa-400f-b282-a13a7f296dac"}