git-worktrees
Skill0 starsChanged 7 days agoMITView on GitHub
Use when parallel work needs separate checkouts of one repo.
- Reads credentials
- Deletes or force-pushes
24 other projects use a version of this.
Adopted by
Most recently taken up by
- denormans/claude-code-workflowtheir own version, first seen Nov 8, 2026
- kazemcodes/skill-treetheir own version, first seen Nov 8, 2026
- Mahesh-Bishnoi/skillstheir own version, first seen Nov 8, 2026
- bostonaholic/rpikittheir own version, first seen Nov 8, 2026
- gabrielkoerich/skillstheir own version, first seen Nov 1, 2026
- lost-rob0t/skillstheir own version, first seen Oct 30, 2026
Used with
Projects with it also use obsidian-bases, verification-before-completion and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
wangzhuofengSkillobsidian-bases
Create and edit Obsidian Bases (.base files) with views, filters, formulas, and summaries. Use when working with .base files, creating database-like views of notes, or when the user mentions Bases, table views, card views, filters, or formulas in Obsidian.
Also in 3 projects that use this
OpenAISkillverification-before-completion
Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always
Also in 4 projects that use this
SentrySkillsecurity-review
Finds exploitable application security vulnerabilities in code changes. Use for Warden security scans, appsec review, OWASP-style checks, authentication or authorization bugs, injection, XSS, SSRF, path traversal, secrets, unsafe crypto, webhook verification, open redirects, or sensitive data exposure.
Also in 4 projects that use this
OpenAISkillsystematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
Also in 4 projects that use this
CloudflareSkillreceiving-code-review
Use when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation
Also in 3 projects that use this
CloudflareSkillsecurity-audit
Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.
Also in 3 projects that use this
- +3 more from openai
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- heyitsnoah/claudesidian★ 2.6ksame name
- jamesrochabrun/skills★ 209same name
- trailofbits/dropkit★ 129same name
- bostonaholic/rpikit★ 19same name
- CarbeneAI/Forge★ 9same name
- sergeeey/Claude-cod-top-2026★ 9same name
- gabrielkoerich/skills★ 8same name
- tstapler/dotfiles★ 8same name
- KhaledSaeed18/dotclaude★ 5same name
- vikisingh23/neuraforge-ai★ 4same name
14 more not listed
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.
In this repository6 other files it gives its agents.
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 24 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 31
Put worktrees in a sibling directory, never inside the repository:
- Very specific: line 152
Use --detach when you only need to look.
“Common” is measured: kept by at least 6 in 10 of the 24 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git worktrees
When to Use
- Two branches must be worked on at once, or a hotfix must not disturb a dirty checkout.
- Several agents (or a human and an agent) work in the same repository simultaneously.
- A review needs the PR branch built and run while
mainstays checked out. - A long build or test run occupies one tree and you still need to commit elsewhere.
A worktree is an extra working directory attached to the same repository: one .git
object store and ref database, many checkouts. Unlike a second git clone, branches, stashes
(config-dependent) and objects are shared, so a commit made in one tree is immediately visible
in the other without a fetch.
1. Layout
Put worktrees in a sibling directory, never inside the repository:
<repos-root>/<host>/<owner>/<repo>/ main clone
<repos-root>/<host>/<owner>/<repo>.worktrees/<branch>/ one tree per branchThe rule matters: a worktree inside the repo would be picked up as untracked files by the
parent, and git status in the parent becomes noise. Keep the branch name in the last path
segment, and use the branch's full name with / replaced by - when it would otherwise nest
(feature/x → feature-x).
cd <repos-root>/<host>/<owner>
git -C <repo> worktree add ../<repo>.worktrees/<branch> -b <branch>cd <repos-root>\<host>\<owner>
git -C <repo> worktree add ..\<repo>.worktrees\<branch> -b <branch>Relative paths resolve against the current directory, not the repository, so prefer an absolute path when scripting — a worktree created from a subdirectory lands somewhere unexpected otherwise.
2. Daily commands
git worktree add <path> <branch> # existing branch
git worktree add <path> -b <branch> [<start>] # new branch from <start> (default HEAD)
git worktree add <path> -B <branch> <start> # create or reset <branch> to <start>
git worktree add --detach <path> <sha-or-tag> # read-only inspection, no branch
git worktree list # path, commit, branch
git worktree list --porcelain # same, machine-readableFor reviewing a pull request without a local branch:
git fetch origin pull/<n>/head:pr-<n>
git worktree add --detach ../<repo>.worktrees/pr-<n> pr-<n>Lifecycle:
git worktree lock <path> --reason "long-running build" # prevents prune
git worktree unlock <path>
git worktree move <path> <new-path>
git worktree remove <path> # refuses if dirty or has untracked files
git worktree remove --force <path> # discard those changes
git worktree remove -f -f <path> # also bypasses a lock (and submodule checks)
git worktree prune # drop admin entries for trees deleted by hand
git worktree prune --dry-run -v
git worktree repair [<path>] # re-link after a directory was movedgit worktree move and repair need git 2.17 and 2.30 respectively —
git --version first if the machine is old.
3. What is NOT shared
This is where worktrees surprise people:
| Item | In a new worktree |
| Tracked files | present at the branch's commit |
.git | a file containing gitdir: <main>/.git/worktrees/<name> |
Ignored/untracked files (.env, keys, local config) | absent |
node_modules, .venv, build caches | absent |
| Stashes | shared (one stash list per repository) |
| Hooks, config | shared |
| Index | separate per worktree |
So a worktree is not a runnable copy until its untracked prerequisites exist. Either copy them deliberately or, for a handful of env files on POSIX, link them:
ln -s ../../<repo>/.env .envOn Windows a symlink needs Developer Mode or Administrator; copying is usually the honest choice. Never commit an env file to make a worktree work.
Anything with per-checkout state needs a per-worktree identity: dev-server ports, database
names, Docker compose project names (docker compose -p <repo>-<branch>), test databases,
and browser profiles. Two worktrees that both claim port 3000 or the same compose project
name will silently fight.
4. Parallel agents
One worktree per agent, one branch per worktree. Two agents in one checkout corrupt each other's index and staging area; their sessions are isolated but the checkout is not.
for b in agent-a agent-b; do
git worktree add "../<repo>.worktrees/$b" -b "$b"
doneGive each its own port range, its own compose project name, and its own scratch directory for logs and artefacts. Merge or open PRs from each branch as usual — the shared object store means no fetching back and forth.
Hermes' own -w / worktree mode does exactly this when spawning agent processes; use it
rather than hand-rolling the same thing.
5. Verify
git worktree list --porcelainEach entry has worktree <path>, HEAD <sha> and either branch refs/heads/<b> or
detached. Check that the paths are where you intended and that no entry is prunable.
Pitfalls
- A branch can only be checked out in one worktree.
git worktree add <path> <branch>fails with "already checked out at" — that is the feature, not an error to work around. Use--detachwhen you only need to look. git branch -d <branch>fails while a worktree has it checked out. Remove the worktree first, or delete with-Dafter removing.- Moving directories breaks the link. Both
.gitand.git/worktrees/<name>/gitdirstore absolute paths. Moving the main clone, or a worktree, leaves a tree that looks fine but cannot run git untilgit worktree repair(run from the main clone; pass paths when several moved). rm -rfa worktree instead ofgit worktree removeleaves an admin entry, and latergit worktree addat the same path says "already registered".git worktree prunefixes it.git worktree removerefuses a dirty tree, including untracked files created by a test run. Commit, stash, or--force— read the diff before forcing.- Submodules are not initialised in a new worktree:
git submodule update --init --recursivethere, after adding. - A
.gitthat is a file breaks naive tooling — scripts and GUIs that assume.gitis a directory (some build scripts, some IDE watchers) fail in linked worktrees only. - Windows path length. The path is stored absolutely and nested
node_modules/.venvtrees can exceed 260 characters. Keep the repos root shallow (C:\src), and enable long paths (git config --global core.longpaths true, plus the OS policy) or expect odd errors. - Disk use grows per checkout with generated files, though objects stay shared. Prune stale worktrees rather than letting them pile up.
git worktreedoes not exist before git 2.5, andadd --orphan/movecame later; an old CI runner is a real place to meet this.
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.

