Recall & Review
beginner
What is a Git worktree?
A Git worktree is an additional working directory linked to the same Git repository. It allows you to work on multiple branches simultaneously without switching branches in a single directory.
Click to reveal answer
beginner
How do you create a new worktree for a branch named
feature?Use the command
git worktree add <path> feature. This creates a new directory at <path> with the feature branch checked out.Click to reveal answer
intermediate
Why use Git worktrees instead of cloning the repository multiple times?
Worktrees share the same Git repository data, saving disk space and keeping history consistent. Cloning multiple times duplicates data and uses more space.
Click to reveal answer
beginner
What command lists all existing Git worktrees?
Run
git worktree list to see all worktrees linked to the repository, including their paths and checked-out branches.Click to reveal answer
intermediate
How do you remove a Git worktree safely?
First, delete the worktree directory manually. Then run
git worktree prune to clean up references to removed worktrees.Click to reveal answer
What does the command
git worktree add ./new-feature feature do?✗ Incorrect
The command adds a new worktree at ./new-feature with the 'feature' branch checked out.
Which command shows all worktrees linked to your Git repository?
✗ Incorrect
git worktree list displays all worktrees connected to the repository.Why might you prefer a Git worktree over cloning the repo multiple times?
✗ Incorrect
Worktrees share the same Git data, saving disk space compared to multiple clones.
What must you do after deleting a worktree directory manually?
✗ Incorrect
After manual deletion,
git worktree prune removes stale references.Can you have multiple worktrees checked out on different branches at the same time?
✗ Incorrect
Worktrees let you work on multiple branches simultaneously in separate directories.
Explain what a Git worktree is and why it is useful.
Think about working on two projects at once without switching folders.
You got /3 concepts.
Describe the steps to create and then remove a Git worktree safely.
Consider how to add a new folder for a branch and clean up after.
You got /3 concepts.