Challenge - 5 Problems
Worktree Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of creating a new worktree
What is the output of the following command if the branch
feature-x does not exist yet?git worktree add ../feature-x feature-xGit
git worktree add ../feature-x feature-xAttempts:
2 left
💡 Hint
The command creates a new branch and a new worktree directory.
✗ Incorrect
The command creates a new worktree at ../feature-x and switches to a new branch named 'feature-x'. The output confirms the preparation and branch switch.
🧠 Conceptual
intermediate1:30remaining
Purpose of git worktree
Which of the following best describes the purpose of using
git worktree?Attempts:
2 left
💡 Hint
Think about working on multiple features at the same time.
✗ Incorrect
git worktree allows you to have multiple working directories from the same repository, each checked out to different branches, so you can work on them simultaneously.❓ Troubleshoot
advanced2:00remaining
Error when adding a worktree
You run the command
What is the most likely cause?
git worktree add ../test-branch origin/test-branch but get the error:fatal: 'origin/test-branch' is not a commit and a branch 'origin/test-branch' cannot be created from it.What is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the remote branch exists before adding a worktree.
✗ Incorrect
Git requires the remote branch 'origin/test-branch' to exist locally or remotely to create a worktree from it. If it doesn't exist, it cannot create the worktree and shows this error.
🔀 Workflow
advanced2:30remaining
Steps to remove a worktree safely
Which sequence of commands correctly removes a git worktree located at
../feature-y and cleans up references?Attempts:
2 left
💡 Hint
Use git commands to remove worktree and branch, then prune.
✗ Incorrect
First remove the worktree with
git worktree remove, then delete the branch with git branch -d, and finally clean up stale worktree references with git worktree prune.✅ Best Practice
expert3:00remaining
Best practice for concurrent feature development
You want to work on two features simultaneously without switching branches in the same directory. Which is the best practice using git worktree?
Attempts:
2 left
💡 Hint
Think about avoiding switching branches in one folder.
✗ Incorrect
Using multiple worktrees allows you to have separate folders for each feature branch, avoiding the need to switch branches and reducing risk of conflicts.