Worktrees
Create, lock, unlock, prune and open, and how sibling worktree HEADs feed Lost Work.
What the app knows about each worktree
Every registered worktree is listed with its path, the branch it has checked out, its HEAD oid, whether it is the main worktree, whether it is locked, how many dirty files it holds, and (when Git says so) the reason it is prunable. A linked worktree can be opened in the catalogue and worked in as a first-class repository.
Create
Creating a worktree checks the things that actually fail: that the path is not already a registered worktree, that the branch name is unused when you are creating one, and that the start point resolves to a commit. It is safe and takes no checkpoint, because nothing existing is overwritten. A new directory is checked out and your current worktree, its branch and its files are untouched.
# on a new branchgit worktree add -b release/2.4 ../atlas-web-release-2.4 main# on an existing branchgit worktree add ../atlas-web-release-2.4 release/2.4
Lock, unlock, prune
Locking marks a worktree so that a prune leaves its registration alone: useful for a checkout on removable media. The plan checks the current lock state first and refuses to lock something already locked, and an optional reason is passed through to Git.
Pruning removes stale registration records, and only those: the plan counts the registrations Git itself reports as prunable, and when there are none it says the operation should be a no-op instead of running blind. It is caution with a light checkpoint, and the plan is clear that a pruned registration can only be brought back by adding the worktree again.
Remove: the one to read before you run it
Removal probes the registered worktree’s own status directly, at its authoritative path rather than at whatever spelling the caller supplied, and counts its staged, unstaged, untracked and conflicted files. A status read that fails stops the plan; it is never treated as “clean”.
| Operation | Risk | Captured first |
|---|---|---|
| Create | safe | Nothing |
| Lock / unlock | safe | Nothing |
| Prune | caution | Light checkpoint: refs, HEAD, index, patches |
| Remove a clean worktree | safe | Nothing |
| Remove a dirty worktree | destructive | Nothing: see below |
A dirty linked worktree is outside capsule scope
This is the one destructive operation in the toolkit that takes no capsule, and the app refuses to imply otherwise. A checkpoint captures the primary worktree; it does not capture files inside a linked one. Forced removal of a dirty worktree therefore destroys those uncommitted changes with no app-side recovery, and both the plan and the rollback section say exactly that. Commit or stash inside the worktree first.
If the worktree being removed is the one currently open in GitAegis, the app switches to the repository’s primary worktree before it executes the approved removal. After success it reloads the catalogue and closes the removed worktree’s tab so a dead path cannot remain selected. If no valid primary worktree can be resolved, removal is refused rather than leaving the application pointed at a directory it just deleted.
How worktrees feed recovery
Lost Work reads the registered worktree list and treats each sibling’s HEAD as a source of candidates: a commit reachable only from another worktree’s HEAD is still findable, labelled with which worktree it came from. That is the HEAD, not the whole reflog of every worktree, and the claim is kept that narrow on purpose.