‹ 首页

git-worktrees

@lexler · 收录于 昨天 · 上游提交 1 周前

Creates git worktrees for parallel development. Use when creating a git worktree, setting up multiple working directories, or working on features in parallel.

适合你,如果经常需要在不同功能分支间快速切换

/ 通过 npx 安装 校验哈希
npx oh-my-skill add lexler/skill-factory/git-worktrees
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- lexler/skill-factory/git-worktrees
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify lexler/skill-factory/git-worktrees
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
223GitHub stars
~255上下文体积 · 单文件
索引托管

怎么用

商店整理自技能原文 · 版本 2eae60e · 表述以原文为准
它做什么

装上后,Claude 可以管理 git worktrees,在项目同级目录下创建专用工作树文件夹,按约定命名分支和目录,支持并行开发。提供创建、列出和清理 worktrees 的命令。

什么时候触发

当你要求创建 git worktree、设置多个工作目录或进行并行开发时触发。

装好后可以这样说
会创建分支并添加工作树
会移除 worktree 并删除分支
显示当前所有工作树
技能原文 SKILL.md作者撰写 · Apache-2.0 · 2eae60e

Git Worktrees

Directory Convention

Worktrees live in a sibling directory named <project>_worktrees:

parent/
├── myproject/              # main repo
└── myproject_worktrees/    # worktrees directory
    ├── feature_1/
    └── feature_2/
Branch Naming

Use <feature>_<N> pattern when creating multiple worktrees:

  • auth-refactor_1, auth-refactor_2
  • api-migration_1, api-migration_2
Workflow
  1. Get project name from current directory
  2. Create worktrees directory if needed: ../<project>_worktrees/
  3. Create worktree with new branch: git worktree add <path> -b <branch>
Creating Multiple Worktrees

When asked for N worktrees for a feature:

PROJECT=$(basename "$PWD")
WORKTREES_DIR="../${PROJECT}_worktrees"
mkdir -p "$WORKTREES_DIR"

for i in $(seq 1 N); do
    git worktree add "${WORKTREES_DIR}/<feature>_${i}" -b "<feature>_${i}"
done
Cleanup

Remove worktree and branch:

git worktree remove <path>
git branch -d <branch>

List all worktrees: git worktree list

按 Apache-2.0 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。