본문으로 건너뛰기
cccskills
무료GitHub에 공개

git-worktree

Use this skill whenever a task involves running parallel work on a git repository without conflicts — e.g. "fix this bug while I keep working on my feature", "run Claude on two branches at once", "work on this task in isolation", "create a throwaway branch for this experiment", or anything where two agents or sessions might edit the same files. Also trigger when the user asks to use worktrees directly, or when an agent needs its own isolated checkout so it can work without disturbing the main branch. Even if the user just says "do this in parallel" or "don't mess up my current work", consider worktrees.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md5.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Git Worktree Skill

Git worktrees let you check out multiple branches of the same repository into separate directories simultaneously. Each directory is a fully independent working tree — its own HEAD, index, and files — but all share the same .git history and objects, so they stay lightweight.

Use this skill to give each agent or parallel task its own isolated workspace.


When to reach for worktrees

  • Two or more agents might edit the same files simultaneously
  • A task should not disturb the current branch's working state
  • You need a throwaway sandbox that can be discarded cleanly if things go wrong
  • The user asks to work on multiple features or fixes in parallel
  • You want to run tests on one branch while editing another

Core commands

Create a worktree

# New branch from current HEAD
git worktree add ../my-task -b my-task-branch

# From a specific commit or existing branch
git worktree add ../hotfix -b hotfix origin/main

# Detached HEAD (no branch)
git worktree add --detach ../scratch HEAD

# Empty worktree on an unborn branch (blank slate)
git worktree add --orphan ../experiment -b experiment

The new directory is ready to use immediately. cd into it and work normally.

List all worktrees

git worktree list
# /path/to/main        abc1234 [main]
# /path/to/my-task     def5678 [my-task-branch]

Remove a worktree when done

# Clean remove (fails if the worktree has uncommitted changes)
git worktree remove ../my-task

# Force remove (discard dirty worktree)
git worktree remove --force ../my-task

# If you deleted the directory manually, clean up the metadata
git worktree prune

Move a worktree

git worktree move ../my-task ../new-location

Lock / unlock (for portable drives or network shares)

git worktree lock ../my-task --reason "on external drive"
git worktree unlock ../my-task

Repair after a manual move

# Run inside the moved worktree
git worktree repair

# Or from main, pointing at each moved worktree
git worktree repair ../new-location-1 ../new-location-2

Recommended layout for agents

Place worktrees as siblings of the main repo directory so paths stay predictable and .gitignore patterns do not need updating:

projects/
  my-app/           ← main repo  (agents work here by default)
  my-app-task-a/    ← worktree for task A
  my-app-task-b/    ← worktree for task B

Create them from the main repo root:

git worktree add ../my-app-task-a -b task-a
git worktree add ../my-app-task-b -b task-b

Agent workflow

  1. Create a worktree on a fresh branch before starting work.
  2. Work entirely inside that directory — treat it like a normal repo.
  3. Commit as usual; history is shared with the main repo.
  4. Verify the result (tests, review, etc.).
  5. Merge or PR the branch back via standard git workflow.
  6. Remove the worktree once done.
# Step 1 — set up
git worktree add ../my-app-fix-login -b fix-login

# Step 2 — work
cd ../my-app-fix-login
# ... make changes ...

# Step 3 — commit
git add -A && git commit -m "fix: resolve login redirect loop"

# Step 4 — back in main repo, merge
cd ../my-app
git merge fix-login

# Step 5 — clean up
git worktree remove ../my-app-fix-login
git branch -d fix-login

Safety rules

  • One branch per worktree. Git prevents the same branch from being checked out in two worktrees at once. Use separate branch names for each worktree.
  • Do not share an index. Never point two worktrees at the same directory.
  • Avoid submodules in moved worktrees. git worktree move cannot move a worktree that contains submodules; handle those manually.
  • Discard freely. If a worktree session goes wrong, git worktree remove --force discards it entirely with no impact on other branches.
  • Prune stale metadata. After manually deleting a worktree directory, run git worktree prune in the main repo to remove orphaned administrative files.

Troubleshooting

SymptomFix
fatal: '<branch>' is already checked outUse a different branch name, or check git worktree list
Worktree directory deleted but git worktree list still shows itRun git worktree prune
Moved worktree can no longer find the repoRun git worktree repair inside the moved directory
Locked worktree blocks removalgit worktree unlock <path> then remove
Changes in worktree not visible in mainChanges are per-worktree until committed and merged

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Safe deployment workflow for Drupal 10/11 sites: pre-flight checks, backup, the correct update sequence (composer install, database updates, config import, cache rebuild), verification, and rollback plan. Use when deploying to any environment, releasing to production, or when the user asks to "push changes live", "update the server", or run a release. Also use for multisite releases where each site needs its own database update pass.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

Use this skill when authoring or editing Docker Compose files (compose.yaml / docker-compose.yml), running multi-container stacks, or containerizing a Drupal/PHP application — e.g. "set up a local Drupal stack with nginx and MariaDB", "add Redis to my compose file", "why won't my containers start", "split dev and prod compose configuration". Also trigger for compose commands (up, down, logs, exec, watch) and healthcheck/dependency issues between services.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

Use this skill when running local AI models with Docker Model Runner — the `docker model` CLI — e.g. "run an LLM locally with Docker", "pull a model from the ai/ namespace", "connect my app to a local model", "use a local model as backend for the Drupal AI module", or when wiring the `models:` top-level element into a compose.yaml. Covers pulling/running models, OpenAI-compatible endpoints, and Compose integration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

Use for operational Drupal 11 workflows in DDEV environments, including safe updates, backup-first procedures, and troubleshooting commands.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

Use when creating or extending Drupal 11 custom modules, including scaffolding, service architecture, and dependency injection best practices.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

Use when auditing Drupal 11 custom modules/themes for security issues such as unsafe input handling, XSS risks, SQL injection, and access control gaps.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

siva01c/claude-plugins162026년 9월 26일 업데이트

siva01c의 스킬 모두 보기

이 스킬의 문제 신고