git-worktree-manager
Managing multiple Git worktrees for parallel work — setup, workflows, and cleanup.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 0
- Forks
- 1
01 前言 Front Matter
- name
- git-worktree-manager
- category
- git
- description
- Managing multiple Git worktrees for parallel work — setup, workflows, and cleanup.
03 SKILL.md 正文
Overview
git worktree lets one repository have multiple checked-out working trees —
work on a hotfix, a feature, and a review simultaneously without stashing or
cloning. Each worktree has its own branch, working directory, and (mostly)
independent state, all sharing one object database. This skill covers the
workflows and hygiene that make worktrees a superpower instead of a mess.
When to use
- Working on two branches in parallel (feature + urgent hotfix)
- Running long tests/builds in one worktree while coding in another
- Reviewing a colleague's branch without disturbing your work
- Setting up a clean worktree for bisecting or experimenting
- Cleaning up stale worktrees safely
Core concepts
One repo, many checkouts. git worktree add ../hotfix hotfix-branch
creates a new directory with that branch checked out. All worktrees share the
same .git object store — no duplicate history, no extra fetch. A branch can
only be checked out in one worktree at a time (Git enforces this).
Worktrees are disposable by design. The power move: create a worktree for
a task, delete it when done (git worktree remove). Unlike clones, there's
no separate remote config to maintain and no duplicated objects. Treat them
as cheap and temporary.
State is per-worktree (mostly). Each worktree has its own index, HEAD, and working tree — but refs, stash, and config are shared repo-wide. Uncommitted changes can't move between worktrees directly (commit or stash first); bisect state and some operations lock the main worktree.
Naming and location conventions. Keep worktrees in a predictable place —
siblings of the main checkout (../project-hotfix) or a dedicated directory
(~/worktrees/project-feature). Descriptive directory names beat remembering
which path holds which branch; git worktree list shows the mapping anytime.
Practical workflow
- Create deliberately:
git worktree add -b new-branch ../project-feat(new branch) orgit worktree add ../project-review origin/pr-branch(existing remote branch, detached or tracked). - Set up per-worktree environment: install dependencies / env files if the project needs them per directory (some tools key off the path — configure accordingly), and open the worktree in a separate editor window.
- Work normally — commit, push, rebase within the worktree; fetches in any worktree update the shared refs for all.
- For reviews: add a worktree at the PR's branch, run tests, read code — your main work stays untouched; remove the worktree after.
- For emergencies: hotfix worktree from
main, fix, test, push, PR — while your feature work sits undisturbed in the main checkout. - Clean up:
git worktree remove ../project-feat(fails if dirty — protecting uncommitted work);git worktree pruneclears metadata for manually deleted directories;git worktree listaudits what's live.
Common pitfalls
- Forgetting worktrees exist — stale worktrees accumulate; audit with
git worktree listregularly and remove finished ones. - Manually deleting the directory without
git worktree remove— leaves stale metadata; follow withgit worktree prune. - Trying to check out the same branch twice — Git refuses; use a differently-named branch or detach HEAD for read-only inspection.
- Assuming stash moves between worktrees — stash is repo-global and applies to whichever worktree you pop in; label stashes clearly.
- IDE/tool confusion — some tools cache by directory and handle
worktrees fine; others (certain Git GUIs, hooks assuming
$PWD) need per-worktree configuration — verify yours. - Running repo-wide operations carelessly —
git gcor filter operations affect all worktrees; coordinate when teammates share the repo (rare, but possible on shared machines).
04 同仓库更多 Skills
web-scrape
Turn web pages into LLM-ready markdown via the Firecrawl API (renders JS, anti-bot handling). Use when browser_open/fetch fails on JS-heavy pages, or when you need clean markdown/structured extraction from a site. Requires FIRECRAWL_API_KEY.
design-taste-frontend
tasteskill v2, the anti-slop frontend skill. Art direction for websites, distilled from a study of 247 curated gallery sites (One Page Love, Awwwards Sites of the Day). Deals researched directions (idea, composition, type, palette, photographs, section blueprints) from a library, enforces a strict no-slop house style with a real-browser inspector, and runs a look-and-fix loop on screenshots. Use this whenever you build, design, redesign, restyle, polish or review a landing page, marketing site, portfolio, product page, one-pager, hero or any public-facing web page, in any stack (HTML/CSS, React, Next.js, Vue, Svelte, Astro, Tailwind) — also when the user says a page looks generic, templated, "AI-made", sloppy, or asks to make it look designed, premium, award-level or less like every other site. Not for dashboards or app screens.
test-driven-development
Use when implementing any feature or bugfix, before writing implementation code
systematic-debugging
Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
requesting-code-review
Use when completing tasks, implementing major features, or before merging to verify work meets requirements
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).