Challenge - 5 Problems
Worktree Removal Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of removing a non-existent worktree?
You run the command
git worktree remove /path/to/nonexistent on a valid git repository. What is the expected output?Git
git worktree remove /path/to/nonexistentAttempts:
2 left
💡 Hint
Think about what happens if you try to remove a worktree that git does not know about.
✗ Incorrect
Git will report a fatal error because the specified path is not recognized as a valid worktree.
🔀 Workflow
intermediate2:30remaining
Correct sequence to safely remove a git worktree
Which sequence of commands correctly removes a git worktree named
feature-branch located at /repos/project/feature-branch?Attempts:
2 left
💡 Hint
Check the worktree status before removal to avoid data loss.
✗ Incorrect
First list worktrees to confirm existence, then check status inside the worktree, then remove it with git, finally delete the directory if needed.
❓ Troubleshoot
advanced2:00remaining
Why does 'git worktree remove' fail with 'worktree is not empty'?
You try to run
git worktree remove /path/to/worktree but get the error error: worktree '/path/to/worktree' is not empty. What is the most likely cause?Attempts:
2 left
💡 Hint
Think about what git expects when removing a worktree directory.
✗ Incorrect
Git refuses to remove a worktree if the directory is not empty to avoid accidental data loss of untracked or modified files.
✅ Best Practice
advanced1:30remaining
Best practice to clean up a worktree after removal
After running
git worktree remove /path/to/worktree, what is the recommended next step to fully clean up the worktree directory?Attempts:
2 left
💡 Hint
Git removes references but not the actual directory files.
✗ Incorrect
Git removes the worktree reference but leaves the directory intact. You must manually delete it to free disk space.
🧠 Conceptual
expert2:30remaining
What happens internally when you remove a git worktree?
When you run
git worktree remove /path/to/worktree, which of the following best describes what git does internally?Attempts:
2 left
💡 Hint
Consider what git can safely do without risking data loss.
✗ Incorrect
Git removes the worktree reference from its internal metadata but leaves the directory untouched to avoid deleting user files.