worktree — checkout 여러 개, repo 하나
고전적 방해 이야기: feature/x 에서 작업 중인데 main 에 긴급 버그 fix 필요, 진행 중 코드가 아직 빌드 안 돼서 stash 못 함. 옛 답은 repo 두 번째 clone. 현대 답은 git worktree: 다른 branch 의 여러 checkout 사본 사이 공유되는 단일 .git/. 같은 commit, 같은 hook, 같은 config — 다른 working tree, 나란히.
git worktree add ../repo-hotfix hotfix/login 이 ../repo-hotfix 에 hotfix/login checkout 된 새 worktree 생성. 원본 worktree ./repo 는 여전히 feature/x. 디렉토리 변경으로 프로젝트 switch, branch 아니라. 공유된 .git/ 는 어느 worktree 의 commit 도 다른 쪽에서 즉시 보임. git worktree list 가 모든 checkout 표시, git worktree remove ../repo-hotfix 가 작업 끝나면 하나 은퇴.
높은 레버리지 사용 사례 셋. 진행 중 작업 중 hotfix — hotfix 를 worktree 로 분기, 고치고 ship, stash 없이 feature 복귀. 장기 비교 / 빌드 — 옛 commit 의 한 worktree 에서 긴 test 돌리면서 원본에서 새 commit 작업 계속. 동료 PR 리뷰 — git worktree add ../repo-pr-142 pr/142 가 main branch checkout 안 흔들고 그들 branch 깨끗이 checkout.
함정 둘. 같은 branch 는 worktree 둘에 동시 checkout 못 해 — Git 거부. (정말 read-only 뷰 원하면 git worktree add --detach.) Worktree 가 disk 소비: 각자 full working-tree 사본, 단 자기 .git/objects/ 없이. 거대 repo 는 secondary worktree 의 partial-clone 이나 sparse-checkout 이 큰 공간 절약. CI 통합도 좋음 — Vercel 류 플랫폼이 각 worktree 독립 배포 가능.