CS FundamentalsModerateTCS · Wipro · Git interview

You staged changes to app.py with git add but now want them out of the next commit while keeping the edits in your working tree. Which command does exactly that?

  1. A. git restore app.py
  2. B. git checkout -- app.py
  3. C. git reset --hard
  4. D. git restore --staged app.py

Correct answer: D. git restore --staged app.py

git restore --staged (like git reset app.py) removes the file from the index but leaves the working-tree edits. git restore app.py and git checkout -- app.py discard working-tree changes; reset --hard discards everything.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic