0
0
Gitdevops~5 mins

Creating a worktree in Git - Quick Revision & Summary

Choose your learning style9 modes available
Recall & Review
beginner
What is a Git worktree?
A Git worktree is an additional working directory linked to the same Git repository. It allows you to work on multiple branches simultaneously without switching branches in a single directory.
Click to reveal answer
beginner
How do you create a new worktree for a branch named feature?
Use the command git worktree add <path> feature. This creates a new directory at <path> with the feature branch checked out.
Click to reveal answer
intermediate
Why use Git worktrees instead of cloning the repository multiple times?
Worktrees share the same Git repository data, saving disk space and keeping history consistent. Cloning multiple times duplicates data and uses more space.
Click to reveal answer
beginner
What command lists all existing Git worktrees?
Run git worktree list to see all worktrees linked to the repository, including their paths and checked-out branches.
Click to reveal answer
intermediate
How do you remove a Git worktree safely?
First, delete the worktree directory manually. Then run git worktree prune to clean up references to removed worktrees.
Click to reveal answer
What does the command git worktree add ./new-feature feature do?
ACreates a new directory ./new-feature with the branch 'feature' checked out
BDeletes the branch 'feature'
CSwitches the current directory to branch 'feature'
DClones the repository into ./new-feature
Which command shows all worktrees linked to your Git repository?
Agit status
Bgit branch -a
Cgit remote -v
Dgit worktree list
Why might you prefer a Git worktree over cloning the repo multiple times?
AWorktrees save disk space by sharing repository data
BWorktrees create separate repositories
CCloning is faster than worktrees
DWorktrees do not support multiple branches
What must you do after deleting a worktree directory manually?
ARun <code>git branch -d</code>
BRun <code>git clone</code>
CRun <code>git worktree prune</code> to clean references
DNothing, Git cleans automatically
Can you have multiple worktrees checked out on different branches at the same time?
ANo, only one worktree can be active
BYes, that is the main benefit of worktrees
CYes, but only if branches are merged
DNo, worktrees share the same branch
Explain what a Git worktree is and why it is useful.
Think about working on two projects at once without switching folders.
You got /3 concepts.
    Describe the steps to create and then remove a Git worktree safely.
    Consider how to add a new folder for a branch and clean up after.
    You got /3 concepts.