using-git-worktrees

Featured

Use when a coding task needs a concurrent checkout, unrelated dirty state blocks safe branch switching, or the user or repository explicitly requires a worktree.

Code & Development 1,179 stars 52 forks Updated yesterday MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
100
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Using Git Worktrees ## Overview A worktree is an exception for simultaneously checking out another Git history, not a general safety badge. Prefer the current workspace and reuse an existing suitable worktree. A branch decision and a worktree decision are separate. **Core principle:** create only with necessity and ownership evidence; pair every created worktree with a cleanup path. **Announce at start:** explain which concrete checkout conflict requires a worktree. ## Step 0: Environment Detection Before mutation, record the repository root, `HEAD`, branch/detached state, staged/unstaged/untracked paths, active Git operations, and: ```bash git worktree list --porcelain ``` Classify the current host surface's task/chat-bound managed workspace semantics as `managed`, `non-managed`, or `unknown`. Use trusted host/session context, an explicit host contract, or a host-native lifecycle result; do not infer the classification from a product name, directory prefix, command-level `workdir`, missing tool, or absent metadata. `non-managed` requires positive evidence that the current surface lacks task-bound managed semantics. When the host exposes workspace fields, record the task workspace and the command's default `cwd` without a per-command directory override. Stop on unresolved conflicts, an active merge/rebase/cherry-pick/revert/bisect, or an unexplained detached HEAD. A detached HEAD is acceptable only when trusted host binding evidence identifies it as the intended st...

Details

Author
GanyuanRan
Repository
GanyuanRan/Aegis
Created
4 months ago
Last Updated
yesterday
Language
Python
License
MIT

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category