Git Worktree
为每个写任务建独立工作树,并在暂停、接手、主工作树脏了或收尾时管理这些树。用于改任何仓库文件之前、用户说“暂停”、接手上一段会话,以及清理工作树时。
Install
npx skills add Dimon94/skills --skill git-worktreegit clone --depth 1 https://github.com/Dimon94/skills.git /tmp/skills
mkdir -p ~/.claude/skills
cp -r /tmp/skills/skills/git-worktree ~/.claude/skills/git-worktreePersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
# Git Worktree 主工作树只做集成:checkout `main`,不直接写。每个写任务(一行文档也算)在自己的树和分支里做。树的建、看、收都走本 Skill 目录下的 `scripts/worktree.sh`,不手写 `git worktree add`。 ```bash WT="<本 Skill 目录>/scripts/worktree.sh" cd "$(bash "$WT" new feat/<scope>)" # 建树,打印路径;可加第二参数作起点 bash "$WT" ls # 在做清单:branch ahead dirty procs last path bash "$WT" gc # 只报告;gc --apply 才回收 ``` ## 1. 写之前建树 改文件前在仓库任一工作树内运行 `new <type>/<scope>`,type 取 `fix`、`feat`、`research`、`chore`、`docs`,之后的读写、测试、提交都在打印出的路径里做。 起点默认是集成基准:本地 `main` 没有自己的提交且有上游时取上游(如 `origin/main`),否则取 `main`。经 PR/MR 合入的项目先 `git fetch`,再建树。集成分支下的子任务把集成分支作为第二参数传入。 - `new` 先回收可证明安全的树,再建新树;工作树数量不限。任务合入后及时回收,废弃任务按用户授权清理。 - 退出码 4 表示分支已存在:那是一棵在做或暂停的树,去接手它,不另起同名任务。 - 新树里 `node_modules`、`.env`、`.venv` 是指向主工作树的软链,不重装、不复制。本任务改了 lockfile 或依赖版本时,删掉该软链再在本树安装。 完成条件:当前目录是新树,`git branch --show-current` 是任务分支。 ## 2. 主工作树脏了 主工作树出现未提交改动就是违规,先盘点再搬走,不 stash(stash 在所有工作树间共享): 1. `git -C <main> status --short` 列出每个路径,逐个判断归属;不属于当前任务的改动不动,报告给用户。 2. 属于当前任务的:在主工作树 `git diff --binary -- <paths> > /tmp/<scope>.patch`,未跟踪文件先 `git add -N` 让它进 diff。 3. `new` 建树,在树里 `git apply /tmp/<scope>.patch`,确认 `git diff --stat` 与原改动一致。 4. 回主工作树 `git restore --staged --worktree -- <paths>`,再删掉搬走的未跟踪文件。 完成条件:主工作树 `git status --short` 不含已搬走的路径,新树含全部改动。 ## 3. 暂停 两个入口:用户明确说暂停;或调用方 Skill 明确授权的上下文交接(如 `implement` 导语里上下文吃紧时的 wip 交接)。两者走同一套步骤。“继续”“我去睡了你接着做”不是暂停,也不构成交接授权。 1. 停在安全边界:做完或退回当前这一步,不开新步骤。 2. 不做不可逆动作:不 push、不建 PR、不碰 `main`。
Details
- Skill name
git-worktree- Repository
- Dimon94/skills
- Path
skills/git-worktree/SKILL.md- Repo updated
- 18 November 2026
FAQ
What does the Git Worktree skill do?
为每个写任务建独立工作树,并在暂停、接手、主工作树脏了或收尾时管理这些树。用于改任何仓库文件之前、用户说“暂停”、接手上一段会话,以及清理工作树时。
How do I install the Git Worktree skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add Dimon94/skills --skill git-worktree. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Git Worktree popular?
It lives in Dimon94/skills, which has 107 GitHub stars and 21 forks.
Related skills
Maintain Verification Skill
107Dimon94/skills
Periodic pass that keeps a project's verification skill and feature map honest: parallel source readers per feature, one live session driving every feature, at most one PR of proven corrections. Use for /maintain-verification-skill or "audit the verify skill".
Create Verification Skill
107Dimon94/skills
Generate a project-local verification skill that drives your app the way a user does — any language, framework, or platform. Use for /create-verification-skill, "make a control skill for this repo", or when a project has no scripted way to prove UI/CLI/service behavior.
How
107Dimon94/skills
Use for "how does X work", code walkthroughs before changing something, and placement / ownership / layering questions ("where should this live", "which package owns this", "is this the right layer"). Explains subsystem architecture, runtime flow, onboarding mental models. Use why for motivation.
Atlassian Readonly Skills
43langpingxue/atlassian-skills
Read-only Python utilities for Jira, Confluence, and Bitbucket integration. Provides read access to issues, search, workflows, pages, pull requests, commit history, and more. Use when users need to query Atlassian products like "get a Jira issue", "search Confluence pages", "view pull request details", or "get commit history". This variant excludes all write operations for token efficiency and safety.
Git Workflow
43aws-samples/sample-kiro-cli-multiagent-development
Git operations, branching strategies, commit conventions, and repository management. Use when working with version control, creating branches, writing commits, or resolving merge conflicts.
Atlassian Skills
43langpingxue/atlassian-skills
Python utilities for Jira, Confluence, and Bitbucket integration. Provides issue management, search, workflows, page management, pull requests, commit history, and more. Use when users need to interact with Atlassian products like "create a Jira issue", "search Confluence pages", "create a pull request", "get commit history", or "update sprint status".
Browse the most popular Claude skills, all git & code review skills, or write your own with the skills generator.