Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 1.3 KB

File metadata and controls

34 lines (26 loc) · 1.3 KB
description Clean up a git worktree after its PR has been merged - verifies merge status and safely removes the worktree directory
model haiku

Cleanup Git Worktree

Safely remove a git worktree directory after its associated PR has been merged to main, preserving branches and leaving the user in the primary repo ready for the next task. Confirm the worktree's branch was merged before any cleanup. Pull main in the primary repo to get the latest state, then verify the branch appears in the merged history.

If the branch is unmerged, stop and explain the situation. Merged work is safe to clean up; unmerged work requires user decision.

Remove only the worktree directory itself. Preserve all branches (local and remote) for git history and potential future reference.

Use git worktree list to find the primary repo location. The current working directory may be inside the worktree being cleaned up, so navigate to the primary repo first.

Worktree directory removed, all branches preserved, user returned to primary repo on main with latest changes pulled.

Celebrate the successful merge with congratulatory language acknowledging the completed work.