0
0
Gitdevops~20 mins

Why worktrees enable parallel work in Git - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Worktree Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How do Git worktrees help with parallel development?

Git worktrees allow you to have multiple working directories linked to the same repository. What is the main advantage of using worktrees for parallel work?

AThey let you work on different branches simultaneously without switching branches in one directory.
BThey automatically merge branches when you switch between them.
CThey create separate repositories on your disk for each branch.
DThey prevent you from committing changes until all branches are synchronized.
Attempts:
2 left
💡 Hint

Think about how switching branches normally affects your working directory.

💻 Command Output
intermediate
2:00remaining
Output of listing Git worktrees

What is the output of the command git worktree list after adding a new worktree for branch feature?

Git
git worktree add ../feature feature
git worktree list
A
/path/to/repo feature
/path/to/feature feature
B
/path/to/repo HEAD
/path/to/feature feature
C
/path/to/repo master
/path/to/feature feature
D
/path/to/repo master
/path/to/feature master
Attempts:
2 left
💡 Hint

Remember the main repository's current branch and the new worktree's branch.

🔀 Workflow
advanced
3:00remaining
Steps to create and use a Git worktree for parallel feature development

Arrange the steps in the correct order to create a new Git worktree for a feature branch and start working on it.

A2,1,3,4
B1,2,3,4
C1,3,2,4
D1,2,4,3
Attempts:
2 left
💡 Hint

Create the branch first, then add the worktree, then move into it, then check status.

Troubleshoot
advanced
2:00remaining
Error when adding a Git worktree for an existing branch

You run git worktree add ../feature feature but get an error: fatal: 'feature' already checked out at '../feature'. What is the cause?

AYou do not have permission to create directories outside the current folder.
BThe main repository is in a detached HEAD state.
CThe branch 'feature' does not exist in the repository.
DThe branch 'feature' is already checked out in another worktree at '../feature'.
Attempts:
2 left
💡 Hint

Check if the branch is already checked out somewhere else.

Best Practice
expert
3:00remaining
Why prefer Git worktrees over cloning for parallel work?

Which is the best reason to use Git worktrees instead of cloning the repository multiple times for parallel development?

AWorktrees share the same .git data, saving disk space and keeping history consistent.
BWorktrees automatically sync changes between branches without manual merges.
CWorktrees create isolated repositories that do not share any data.
DWorktrees allow pushing to remote repositories without authentication.
Attempts:
2 left
💡 Hint

Think about disk space and repository data duplication.