0
0
Gitdevops~20 mins

Removing worktrees in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Worktree Removal Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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/nonexistent
Afatal: '/path/to/nonexistent' is not a working tree
BWorktree '/path/to/nonexistent' removed successfully
Cerror: pathspec '/path/to/nonexistent' did not match any files
Dwarning: worktree '/path/to/nonexistent' is already removed
Attempts:
2 left
💡 Hint
Think about what happens if you try to remove a worktree that git does not know about.
🔀 Workflow
intermediate
2: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?
A3,1,2,4
B1,2,3,4
C1,2,4,3
D1,3,2,4
Attempts:
2 left
💡 Hint
Check the worktree status before removal to avoid data loss.
Troubleshoot
advanced
2: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?
AThe worktree directory contains untracked or modified files preventing removal
BThe main repository is corrupted and cannot remove worktrees
CThe worktree path is a symbolic link, which git does not support
DThe git version is outdated and does not support removing worktrees
Attempts:
2 left
💡 Hint
Think about what git expects when removing a worktree directory.
Best Practice
advanced
1: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?
ANothing, git automatically deletes the directory
BManually delete the worktree directory with <code>rm -rf /path/to/worktree</code>
CRun <code>git prune</code> to remove dangling commits
DRun <code>git gc</code> to clean up the repository
Attempts:
2 left
💡 Hint
Git removes references but not the actual directory files.
🧠 Conceptual
expert
2: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?
AGit archives the worktree contents and removes the branch from the repository
BGit resets the worktree to the main branch and deletes all untracked files
CGit removes the worktree reference from the repository's metadata but does not delete the directory
DGit deletes the worktree directory and removes its reference from the main repository's config
Attempts:
2 left
💡 Hint
Consider what git can safely do without risking data loss.