Describe the bug
Deleting a project session from the Copilot desktop app removes the session from the session list, but its git worktree is left behind entirely:
- the worktree folder under
copilot-worktrees/<project>/<slug> still exists on disk
- the worktree is still registered in the main repo (
git worktree list shows it)
- the session branch still exists
This is inconsistent with archive_session, whose documented behavior is to remove the worktree, and there is no documentation stating that delete keeps the worktree. Over time this accumulates orphaned worktrees and branches (see #3675).
Affected version
GitHub Copilot CLI 1.0.78
Steps to reproduce the behavior
- Configure a local project whose repo lives inside WSL (
\\wsl.localhost\Ubuntu\home\...).
- Create a new session for the project (a worktree is created under
copilot-worktrees/<project>/<slug>).
- Delete the session from the app.
- Session disappears from the list, but the worktree folder,
git worktree list entry, and branch all remain.
Reproduced twice with different sessions.
Expected behavior
Deleting a session should remove its worktree (folder + git registration) and ideally the session branch, or at minimum document the behavior and offer a cleanup action. Related: #3675, #4246.
Additional context
On the first attempt, deletion also surfaced a partial-failure error caused by Windows git's ownership check on WSL UNC paths:
Failed to delete session: git ["--no-optional-locks", "status", "--porcelain=v1", "-b", "-M", "-uall"] failed:
fatal: detected dubious ownership in repository at '//wsl.localhost/Ubuntu/home/.../projects/copilot-worktrees/...'
Even after that error, the session record was removed while cleanup was skipped — a partial delete leaving inconsistent state. After adding safe.directory = //wsl.localhost/Ubuntu/home/.../projects/* (git 2.53), deletion completes without error but the worktree is still not cleaned up, so the missing cleanup is not caused by the ownership check.
Describe the bug
Deleting a project session from the Copilot desktop app removes the session from the session list, but its git worktree is left behind entirely:
copilot-worktrees/<project>/<slug>still exists on diskgit worktree listshows it)This is inconsistent with
archive_session, whose documented behavior is to remove the worktree, and there is no documentation stating that delete keeps the worktree. Over time this accumulates orphaned worktrees and branches (see #3675).Affected version
GitHub Copilot CLI 1.0.78
Steps to reproduce the behavior
\\wsl.localhost\Ubuntu\home\...).copilot-worktrees/<project>/<slug>).git worktree listentry, and branch all remain.Reproduced twice with different sessions.
Expected behavior
Deleting a session should remove its worktree (folder + git registration) and ideally the session branch, or at minimum document the behavior and offer a cleanup action. Related: #3675, #4246.
Additional context
On the first attempt, deletion also surfaced a partial-failure error caused by Windows git's ownership check on WSL UNC paths:
Even after that error, the session record was removed while cleanup was skipped — a partial delete leaving inconsistent state. After adding
safe.directory = //wsl.localhost/Ubuntu/home/.../projects/*(git 2.53), deletion completes without error but the worktree is still not cleaned up, so the missing cleanup is not caused by the ownership check.