agentsclimarketplace

Using git worktrees

Skill ComeOnOliver/skillshub/skills/aiskillstore/marketplace/doyajin174/using-git-worktrees

๐Ÿง  The right skill, one API call. AI agent skills registry with token-efficient skill resolution. 5,000+ skills from 500+ top repos.

Install
npx -y skills add ComeOnOliver/skillshub --skill using-git-worktrees

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

What its author says it does

Copied from the file, not written here

Create isolated git worktrees with smart directory selection and safety verification. Use this when starting feature work that needs isolation, parallel development, or safe experimentation.

The file declares its own license as MIT. That is the authorโ€™s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

3.9 KB, as published. Nobody here has run it

Using Git Worktrees

Git worktree๋ฅผ ์‚ฌ์šฉํ•œ ๊ฒฉ๋ฆฌ๋œ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ์ƒ์„ฑ ๊ฐ€์ด๋“œ์ž…๋‹ˆ๋‹ค.

When to Use

  • ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ์„ ์œ„ํ•œ ๊ฒฉ๋ฆฌ๋œ ํ™˜๊ฒฝ ํ•„์š” ์‹œ
  • ์—ฌ๋Ÿฌ ๋ธŒ๋žœ์น˜์—์„œ ๋™์‹œ ์ž‘์—… ์‹œ
  • ์•ˆ์ „ํ•œ ์‹คํ—˜์ด ํ•„์š”ํ•  ๋•Œ
  • ๊ตฌํ˜„ ๊ณ„ํš ์‹คํ–‰ ์ „ ํ™˜๊ฒฝ ์ค€๋น„ ์‹œ

Quick Start

# 1. worktree ๋””๋ ‰ํ† ๋ฆฌ ํ™•์ธ/์ƒ์„ฑ
ls -la ../worktrees/ 2>/dev/null || mkdir -p ../worktrees

# 2. ์ƒˆ worktree ์ƒ์„ฑ
git worktree add ../worktrees/feature-name -b feature/feature-name

# 3. worktree๋กœ ์ด๋™
cd ../worktrees/feature-name

# 4. ์ž‘์—… ์™„๋ฃŒ ํ›„ ์ •๋ฆฌ
git worktree remove ../worktrees/feature-name

Directory Selection Strategy

๊ถŒ์žฅ ๊ตฌ์กฐ

project-root/
โ”œโ”€โ”€ .git/                    # ๋ฉ”์ธ ์ €์žฅ์†Œ
โ”œโ”€โ”€ src/                     # ๋ฉ”์ธ ์ž‘์—… ๋””๋ ‰ํ† ๋ฆฌ
โ””โ”€โ”€ ...

../worktrees/                # worktree ์ „์šฉ ๋””๋ ‰ํ† ๋ฆฌ
โ”œโ”€โ”€ feature-auth/           # ์ธ์ฆ ๊ธฐ๋Šฅ ์ž‘์—…
โ”œโ”€โ”€ feature-api/            # API ๊ฐœ๋ฐœ
โ””โ”€โ”€ hotfix-critical/        # ๊ธด๊ธ‰ ์ˆ˜์ •

๋„ค์ด๋ฐ ๊ทœ์น™

../worktrees/{type}-{name}

types:
- feature-*    ๊ธฐ๋Šฅ ๊ฐœ๋ฐœ
- hotfix-*     ๊ธด๊ธ‰ ์ˆ˜์ •
- experiment-* ์‹คํ—˜์  ๋ณ€๊ฒฝ
- review-*     ์ฝ”๋“œ ๋ฆฌ๋ทฐ์šฉ

Safety Verification

์ƒ์„ฑ ์ „ ์ฒดํฌ๋ฆฌ์ŠคํŠธ

# 1. ํ˜„์žฌ ์ƒํƒœ ํ™•์ธ
git status                    # ๋ฏธ์ปค๋ฐ‹ ๋ณ€๊ฒฝ์‚ฌํ•ญ ํ™•์ธ
git stash list               # stash ์ƒํƒœ ํ™•์ธ

# 2. ๋ธŒ๋žœ์น˜ ์กด์žฌ ์—ฌ๋ถ€ ํ™•์ธ
git branch -a | grep feature-name

# 3. worktree ๋ชฉ๋ก ํ™•์ธ
git worktree list

์ƒ์„ฑ ํ›„ ๊ฒ€์ฆ

# 1. worktree ์ƒํƒœ ํ™•์ธ
git worktree list

# 2. ํ˜„์žฌ ๋ธŒ๋žœ์น˜ ํ™•์ธ
git branch

# 3. ์›๊ฒฉ ์—ฐ๊ฒฐ ํ™•์ธ
git remote -v

Common Workflows

๊ธฐ๋Šฅ ๊ฐœ๋ฐœ ์‹œ์ž‘

# 1. ์ตœ์‹  main ๊ธฐ์ค€์œผ๋กœ worktree ์ƒ์„ฑ
git fetch origin
git worktree add ../worktrees/feature-x -b feature/x origin/main

# 2. ์˜์กด์„ฑ ์„ค์น˜ (ํ”„๋กœ์ ํŠธ์— ๋”ฐ๋ผ)
cd ../worktrees/feature-x
npm install  # ๋˜๋Š” pip install -r requirements.txt

# 3. ๊ฐœ๋ฐœ ์‹œ์ž‘
code .  # ๋˜๋Š” ์›ํ•˜๋Š” ์—๋””ํ„ฐ

์ฝ”๋“œ ๋ฆฌ๋ทฐ์šฉ ํ™˜๊ฒฝ

# PR ๋ธŒ๋žœ์น˜๋ฅผ ๋ณ„๋„ worktree๋กœ
git worktree add ../worktrees/review-pr-123 origin/feature/pr-123
cd ../worktrees/review-pr-123
# ํ…Œ์ŠคํŠธ ์‹คํ–‰, ์ฝ”๋“œ ๊ฒ€ํ† 

๊ธด๊ธ‰ ์ˆ˜์ •

# ํ˜„์žฌ ์ž‘์—… ์ค‘๋‹จ ์—†์ด hotfix
git worktree add ../worktrees/hotfix-critical -b hotfix/critical origin/main
cd ../worktrees/hotfix-critical
# ์ˆ˜์ • โ†’ ์ปค๋ฐ‹ โ†’ PR

Cleanup

๊ฐœ๋ณ„ worktree ์ œ๊ฑฐ

# 1. worktree ์ œ๊ฑฐ
git worktree remove ../worktrees/feature-x

# 2. ๋ธŒ๋žœ์น˜๋„ ์‚ญ์ œํ•˜๋ ค๋ฉด
git branch -d feature/x

์ „์ฒด ์ •๋ฆฌ

# 1. ๋ชจ๋“  worktree ๋ชฉ๋ก
git worktree list

# 2. ์ •๋ฆฌ (์‚ญ์ œ๋œ worktree ์ฐธ์กฐ ์ œ๊ฑฐ)
git worktree prune

# 3. ๋ฏธ์‚ฌ์šฉ worktree ๋””๋ ‰ํ† ๋ฆฌ ์‚ญ์ œ
rm -rf ../worktrees/old-feature
git worktree prune

Best Practices

  1. ์ผ๊ด€๋œ ์œ„์น˜: worktree๋Š” ํ•ญ์ƒ ../worktrees/์—
  2. ๋ช…ํ™•ํ•œ ๋„ค์ด๋ฐ: ๋ชฉ์ ์ด ๋“œ๋Ÿฌ๋‚˜๋Š” ์ด๋ฆ„ ์‚ฌ์šฉ
  3. ์ •๊ธฐ์  ์ •๋ฆฌ: ์™„๋ฃŒ๋œ worktree๋Š” ์ฆ‰์‹œ ์ œ๊ฑฐ
  4. ๋…๋ฆฝ์  ์˜์กด์„ฑ: ๊ฐ worktree์—์„œ ๋ณ„๋„๋กœ ์˜์กด์„ฑ ์„ค์น˜
  5. ๋ฉ”์ธ ์ €์žฅ์†Œ ๋ณด์กด: worktree์—์„œ๋งŒ ์‹คํ—˜์  ๋ณ€๊ฒฝ

Troubleshooting

๋ฌธ์ œํ•ด๊ฒฐ์ฑ…
"already checked out"๋‹ค๋ฅธ worktree์—์„œ ์‚ฌ์šฉ ์ค‘, ๋‹ค๋ฅธ ๋ธŒ๋žœ์น˜๋ช… ์‚ฌ์šฉ
"not a valid ref"git fetch ๋จผ์ € ์‹คํ–‰
์˜์กด์„ฑ ์˜ค๋ฅ˜worktree์—์„œ ์ƒˆ๋กœ ์„ค์น˜ ํ•„์š”
๋ณ€๊ฒฝ์‚ฌํ•ญ ์ถฉ๋Œ๋ฉ”์ธ์—์„œ stash ๋˜๋Š” commit ํ›„ ์ง„ํ–‰

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.