Przejdลบ do treล›ci

๐ŸŒฒ Git Worktrees

Git worktrees allow you to check out multiple branches simultaneously without cloning the repository again.


๐ŸŽ“ Who This Is For

  • Beginners learning multi-branch workflows
  • Intermediate users working on parallel tasks
  • Advanced engineers needing structured reference
  • DevOps and developers managing complex repositories

๐Ÿงฉ What Worktrees Solve

  • Switching branches without stashing
  • Working on multiple features at once
  • Testing or reviewing code in parallel
  • Avoiding dirty working directories

๐Ÿ”ง Create a New Worktree

1
git worktree add ../feature-login feature/login

This creates a new directory and checks out the branch there.


๐Ÿ”ง List Worktrees

1
git worktree list

๐Ÿ”ง Remove a Worktree

1
git worktree remove ../feature-login

๐Ÿง  Best Practices

  • Use worktrees instead of stashing for parallel work
  • Keep worktrees small and focused
  • Avoid deleting worktree directories manually