CS FundamentalsHardProduct-company placement · Git

A developer uses git worktree add ../hotfix main while her current directory has feature checked out. Which statement is correct?

  1. A. It clones the repository again, so the two directories get separate object stores
  2. B. It switches the current directory to main and moves the feature checkout to ../hotfix
  3. C. It adds a second working directory on main sharing this repository; one branch can't be checked out twice
  4. D. It stashes feature's uncommitted changes so that they can be applied inside ../hotfix

Correct answer: C. It adds a second working directory on main sharing this repository; one branch can't be checked out twice

Worktrees share one .git object database and refs, so commits made in either are visible to both, but each has its own HEAD and index. Git blocks checking out one branch in two worktrees to avoid conflicting updates.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic