CS FundamentalsHardWipro · Accenture pattern

How many of the following statements about git reset are correct? 1. git reset --mixed HEAD~1 removes the last commit and leaves its changes unstaged in the working directory. 2. git reset --hard HEAD discards both staged and unstaged changes to tracked files. 3. git reset --hard also deletes untracked files. 4. A commit lost through git reset --hard can usually be recovered with git reflog.

  1. A. Only one
  2. B. Only two
  3. C. Only three
  4. D. All four

Correct answer: C. Only three

1, 2 and 4 are correct. 3 is wrong: reset --hard leaves untracked files alone; git clean -fd removes them. Commits stay reachable through the reflog until it expires, so they can be restored. So three are correct.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic