🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Undoing Changes: all 10 questions

Quiz: Undoing Changes · Question 8 of 10

What does git reset --hard HEAD~1 do?

What does git reset --hard HEAD~1 do?

  1. A.Creates a new commit undoing the last one
  2. B.Moves the branch back but keeps changes staged
  3. C.Moves the branch back one commit and discards that commit's changes from your files
  4. D.Deletes the remote branch
Answer & explanation

Correct answer: Moves the branch back one commit and discards that commit's changes from your files

--hard also resets the staging area and working directory; use it with care.

Can you get the rest right without peeking?

Take the timed Quiz: Undoing Changes quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →