wtcleanup

Replay worktree branch commits onto master as linear history, then remove the worktree and branch.

1|Updated Dec 18, 2009
One-click install
npx skills add https://github.com/thurn/dotfiles --skill wtcleanup-thurn
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: wtcleanup
Source: https://github.com/thurn/dotfiles/tree/main/.llms/skills/wtcleanup
Command: npx skills add https://github.com/thurn/dotfiles --skill wtcleanup-thurn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Finishing a task developed in a Git worktree requires manually promoting its commits onto master without rewriting published history, then cleaning up the worktree and branch—an error-prone process where a wrong rebase can silently rewrite master's commits and diverge from origin. ## Core Features & Use Cases - Linear History Promotion: Replays the worktree branch's unique commits onto master via fast-forward merge or ordered cherry-pick, keeping each commit separate without squashing or merging. - Safe Fallback Logic: Tries merge --ff-only first and falls back to cherry-pick master..branch when master has advanced, avoiding the dangerous git rebase that rewrites published commits. - Protected Cleanup: Removes the worktree and deletes its branch only after promotion succeeds, and never touches untracked or modified files in the user's primary working tree. - Use Case: After finishing a feature in a worktree created by the wt skill, invoke this skill to land those commits on master as a clean linear history and dispose of the temporary worktree. ## Quick Start Ask the AI to run the wtcleanup skill to promote the current worktree's commits onto master and remove the worktree and its branch.

Frequently Asked Questions about wtcleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I move commits from a Git worktree branch onto master?▼

Check out master and first try git merge --ff-only with the worktree branch. If master has advanced, use git cherry-pick master..branch to replay the branch's unique commits in order, resolving conflicts as they arise.

How do I remove a Git worktree and its branch after merging?▼

Run git worktree remove with the worktree path, then git branch -D with the branch name. Only do this after the commits have been successfully promoted onto master, since branch -D force-deletes the branch.

Why should I avoid git rebase when promoting worktree commits to master?▼

Running git rebase branch while on master replays master's own commits on top of the branch, rewriting already-published commits so they diverge from origin/master and require a force-push. Use merge --ff-only or cherry-pick instead.

What happens to uncommitted files in the primary working tree during promotion?▼

Untracked and modified files in the primary working tree are left exactly as they are. The promotion only cherry-picks or merges the worktree branch's commits and never runs git clean, checkout --, or stash on the user's files.

What if the cherry-pick of worktree commits has conflicts?▼

Resolve each conflict as it arises during the cherry-pick, keeping every commit separate rather than squashing. Afterward, verify with git log --oneline that master is a linear history and has not diverged from origin/master.