Recover work from a worktree
Check a worktree before deleting it
Section titled “Check a worktree before deleting it”From inside the worktree:
graft status agent/my-branchIt lists uncommitted paths and local commits no branch on GitHub contains, checked through the API. nothing local that GitHub does not have means it is safe to remove.
If the work is merged, graft worktree done agent/my-branch rewinds the branch so worktree tools stop counting published commits as lost. It exits 1, changing nothing, if anything is local only. With graft’s hooks wired, ExitWorktree remove runs it for you and is refused when something is local only.
Find why cambium kept a worktree
Section titled “Find why cambium kept a worktree”cambium removes a worker’s worktree only when GitHub holds everything in it. Otherwise it keeps it and logs a warning with the reason in ~/.cambium/logs/cambium.log.
To see what the periodic sweep would do with every worktree:
cambium gc --dry-run --repo owner/nameRestore an archived worktree
Section titled “Restore an archived worktree”A worktree idle for gc.staleDays (14 by default) with unpublished work is archived, then removed:
~/.cambium/gc/<owner>__<name>/<dir>-<stamp>/ commits.bundle local commits not on origin/<base> changes.patch uncommitted changes untracked/ untracked files worktree.json where it was and which branch-
Restore the commits into your clone:
Terminal window git fetch ~/.cambium/gc/owner__name/<dir>-<stamp>/commits.bundle HEAD:recovered -
Check out
recovered, then apply the rest:Terminal window git apply ~/.cambium/gc/owner__name/<dir>-<stamp>/changes.patchcp -R ~/.cambium/gc/owner__name/<dir>-<stamp>/untracked/. .
To change when the sweep runs or archives, set gc.everyMinutes, gc.graceMinutes and gc.staleDays: cambium configuration.