본문 바로가기
C.W.K.
Stream
Lesson 11 of 13 · published

Git 연동과 Worktree

~18 min · git, worktrees, checkpoints, rewind, parallel

Level 0🌱 입문자
0 XP0/70 lessons0/11 achievements
0/120 XP to next level120 XP to go0% complete

worktree로 병렬 작업을 파일 충돌 없이 나눠

Claude Code는 파일 편집마다 checkpoint를 남기고 /rewind나 Esc 두 번으로 최근 변경을 되돌릴 수 있어. Git과 가까이 붙어 있기 때문에 commit, branch, rebase, PR 작성도 자연어로 이어지지. 여러 작업을 동시에 벌일 때는 worktree가 한 단계 더 큰 안전장치가 돼.

git worktree add는 같은 저장소의 다른 branch를 별도 디렉터리에 펼쳐. commit 기록은 공유하지만 작업 파일은 분리되므로 각 디렉터리에서 Claude 세션을 하나씩 열어도 서로 덮어쓰지 않아. 반쯤 끝난 작업을 stash로 계속 바꾸는 고통도 사라지고.

--worktree <name>은 이 준비를 자동화하고, /batch는 큰 리팩터링을 독립 단위로 나눠 각 worktree의 백그라운드 에이전트에게 맡길 수 있어. 다만 저장소가 worktree를 금지하거나 공유 checkout을 기준으로 운영한다면 그 집의 규칙이 먼저야.

직접 확인할 항목: .claude/worktrees/<name>/, Esc Esc.

Code

stash 없이 여러 세션 병렬로 돌리기·bash
# Three worktrees in three terminals
claude --worktree feature-auth     "implement OAuth2 login"
claude --worktree bugfix-payment   "fix the null in checkout"
claude --worktree perf-search      "profile and fix slow search"

# All three running simultaneously
# Each touches its own files, all share git history

# Manual equivalent
git worktree add -b feat/x ../x origin/main
cd ../x && claude

# Cleanup when shipped
git worktree remove ../x
/batch로 여러 에이전트에 한 번에 맡기기·bash
# Inside a session
/batch migrate every Express 4 route in src/routes/ to Express 5

# Claude:
# 1. Lists matching files (decomposition)
# 2. Shows you a plan with one unit per file
# 3. On approval: spawns one background agent per unit
# 4. Each agent in its own worktree, implements, runs tests
# 5. Each unit opens its own PR
# You review and merge independently

External links

Exercise

실제 저장소에서 Worktree 두 개를 만들고 Claude 세션도 두 개 실행해. 각 세션에 같은 코드베이스의 서로 다른 작업을 맡기고 파일 충돌 없이 진행되는지 확인해. 이 방식이 git stash로 병렬 작업할 때와 어떻게 다른지도 적어 봐.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.