managing-git-worktrees
Skill1 starsChanged 11 months agoMITView on GitHub
Manages Git worktrees safely: add, list, remove, prune, lock/unlock. Activates on "git worktree", parallel branch work, or errors like "already checked out".
1 other project uses a version of this.
Adopted by
Most recently taken up by
- chewygumxx/agentic-librarytheir own version, first seen Nov 29, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- chewygumxx/agentic-library★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Never discard uncommitted work: - Check git -C <path> status --porcelain before destructive operations
- Very specific: line 11
Inspect before mutate: - Run --dry-run before prune, list before remove
- Very specific: line 12
Avoid
--ignore-other-worktrees: - Treat as last resort, require explicit confirmation - Distinctive: line 13
Quote paths with spaces: - Use forward slashes
- Distinctive: line 37
If start-point is ambiguous:
- Distinctive: line 55
Use existing worktree: - Check path via git worktree list --porcelain
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Managing Git Worktrees
Safety Rules (MUST follow)
- Never discard uncommitted work - Check
git -C <path> status --porcelainbefore destructive operations - Inspect before mutate - Run
--dry-runbeforeprune,listbeforeremove - Avoid
--ignore-other-worktrees- Treat as last resort, require explicit confirmation - Quote paths with spaces - Use forward slashes
Command Reference
| Task | Command |
| List all | git worktree list |
| List (machine) | git worktree list --porcelain |
| Add existing branch | git worktree add <path> <branch> |
| Add new branch | git worktree add -b <new-branch> <path> <start-point> |
| Add detached | git worktree add --detach <path> <commit-ish> |
| Remove (clean only) | git worktree remove <path> |
| Prune dry-run | git worktree prune --dry-run |
| Prune | git worktree prune |
| Lock | git worktree lock <path> |
| Unlock | git worktree unlock <path> |
Workflow: Add Worktree for New Task
git worktree add -b <new-branch> ../wt/<new-branch> <start-point>
git -C ../wt/<new-branch> statusIf start-point is ambiguous:
git show-ref --heads --remotes | grep <branch-name>Workflow: Add Worktree for Existing Branch
git branch --list <branch>
git worktree list --porcelain
git worktree add <path> <branch>Error: "branch is already checked out"
Resolution order (safest first):
- Use existing worktree - Check path via
git worktree list --porcelain - Create new branch -
git worktree add -b <new-branch> <path> <branch> - Detached HEAD -
git worktree add --detach <path> $(git rev-parse <branch>) - Force (last resort) - Requires explicit user confirmation:
git switch --ignore-other-worktrees <branch>
Workflow: Cleanup
git worktree list --porcelain
git -C <path> status --porcelain
git worktree remove <path>
git worktree prune --dry-run
git worktree pruneLocked worktree removal (requires explicit confirmation):
git worktree unlock <path>
git worktree remove <path>
# or force (double --force for locked):
git worktree remove --force --force <path>Response Guidelines
- Brief recommendation (1-3 sentences)
- Copy-paste command block
- Safety note if destructive
- Fallback if first attempt may fail
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

