Table Of Contents
What is a Git worktree?
Why use worktrees instead of several clones?
A practical directory convention
Everyday Git worktree commands
Consolidating several independent clones
Safety rules before starting
Phase 1: Inventory every clone
Phase 2: Choose the canonical repository
Phase 3: Decide what each clone should become
Phase 4: Convert one clone
Moving a worktree
Recovering a deleted .git worktree file
When should a worktree be locked?
When should git worktree prune be used?
Final validation
Quick reference
Closing thoughts
Have you ever ended up with a directory structure like this?
~/src/project
~/src2/project
~/src3/project
~/src4/project
Each directory started innocently enough.
One was for main. Another was for a feature branch. A third contained a half-finished experiment. The fourth had several untracked test files you were afraid to lose.
Eventually, each clone had its own:
stale view of the remote repository,
duplicated Git history,
Discussion
Say something first
It all starts with you—share your thoughts now.