0
0
Gitdevops~20 mins

Listing worktrees in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Worktree 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 git worktree list after adding a new worktree?
You have a main repository and you run git worktree add ../feature-branch feature. What will git worktree list show?
A
../feature-branch 123abc [detached HEAD]
.
B
../feature-branch 123abc [master]
.
CNo output, command fails
D
../feature-branch 123abc [feature]
.
Attempts:
2 left
💡 Hint
The new worktree points to the branch you specify, not master or detached HEAD.
🧠 Conceptual
intermediate
1:30remaining
Which command correctly lists all worktrees with their paths and HEAD commits?
You want to see all worktrees linked to your repository with their paths and current HEAD commit hashes. Which command do you use?
Agit worktree show
Bgit worktree list
Cgit worktree status
Dgit worktree info
Attempts:
2 left
💡 Hint
The command to list worktrees is simple and direct.
Troubleshoot
advanced
2:00remaining
Why does git worktree list show only one worktree after adding multiple?
You added two worktrees using git worktree add but git worktree list shows only one. What is the most likely cause?
AThe second worktree was added outside the main repository folder and not linked properly
BYou need to run <code>git worktree refresh</code> to update the list
CThe second worktree was added but on a detached HEAD, so it is hidden
DThe <code>git worktree list</code> command only shows the main worktree by default
Attempts:
2 left
💡 Hint
Worktrees must be linked inside the repository's control.
Best Practice
advanced
2:00remaining
What is the recommended way to clean up unused worktrees?
You have several worktrees listed by git worktree list but some are no longer needed. What is the best practice to remove them?
AJust delete the folder; Git will auto-detect and clean later
BRun <code>git worktree prune</code> without removing folders
CUse <code>git worktree remove &lt;path&gt;</code> to safely remove the worktree
DDelete the worktree folder manually and run <code>git gc</code>
Attempts:
2 left
💡 Hint
Git provides a command to safely remove worktrees.
🔀 Workflow
expert
3:00remaining
In what order do these commands list and clean worktrees safely?
Arrange these commands in the correct order to list all worktrees, remove an unused one, and then verify cleanup:
A1,2,3,4
B2,1,3,4
C1,3,2,4
D1,2,4,3
Attempts:
2 left
💡 Hint
First list, then remove, prune, and list again to confirm.