CS FundamentalsHardProduct-company placement · Git interview

On main you need the version of config.yml that exists on branch release, without merging anything else. Which command does this, and what state does it leave?

  1. A. git checkout release -- config.yml; the file is replaced in the working tree and staged, ready to commit on main
  2. B. git merge release config.yml; it creates a merge commit
  3. C. git cherry-pick release config.yml; it copies one commit
  4. D. git pull release config.yml; it fetches the file

Correct answer: A. git checkout release -- config.yml; the file is replaced in the working tree and staged, ready to commit on main

Giving a branch and a path checks out that path's content from the branch into both the index and the working tree (git restore --source=release --staged --worktree config.yml is the newer equivalent). Nothing else changes.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic