Git worktrees allow you to have multiple working directories linked to the same repository. What is the main advantage of using worktrees for parallel work?
Think about how switching branches normally affects your working directory.
Worktrees allow multiple working directories to exist for the same repository, each checked out to a different branch. This means you can work on multiple branches at the same time without switching back and forth in one directory.
What is the output of the command git worktree list after adding a new worktree for branch feature?
git worktree add ../feature feature git worktree list
Remember the main repository's current branch and the new worktree's branch.
The main repository remains on its current branch (usually master), and the new worktree is checked out to the specified branch (feature). The list shows both paths with their branches.
Arrange the steps in the correct order to create a new Git worktree for a feature branch and start working on it.
Create the branch first, then add the worktree, then move into it, then check status.
You first create the branch, then add a worktree for it, change directory to the new worktree, and finally check the status to confirm.
You run git worktree add ../feature feature but get an error: fatal: 'feature' already checked out at '../feature'. What is the cause?
Check if the branch is already checked out somewhere else.
Git prevents checking out the same branch in multiple worktrees. The error means 'feature' is already checked out in the specified path.
Which is the best reason to use Git worktrees instead of cloning the repository multiple times for parallel development?
Think about disk space and repository data duplication.
Worktrees share the same Git data, so they use less disk space and keep history consistent. Cloning duplicates the entire repository data.