using-git-worktrees

Installation
SKILL.md

使用 Git 工作树

概述

确保工作发生在隔离的工作区中。优先使用你的平台的原生 worktree 工具。仅在没有原生工具可用时,再回退到手动 git worktree。

核心原则: 先检测现有隔离。然后用原生工具。再回退到 git。绝不与 harness 对抗。

开始时宣布: "我正在使用 using-git-worktrees 技能来建立一个隔离的工作区。"

步骤 0:检测现有隔离

创建任何东西之前,先检查你是否已经在一个隔离的工作区里。

GIT_DIR=$(cd "$(git rev-parse --git-dir)" 2>/dev/null && pwd -P)
GIT_COMMON=$(cd "$(git rev-parse --git-common-dir)" 2>/dev/null && pwd -P)
BRANCH=$(git branch --show-current)
Related skills
Installs
243
GitHub Stars
3.1K
First Seen
Mar 21, 2026