Which Git command is used to undo the last commit while keeping the changes in the working directory?

  • git reset HEAD~1
  • git revert HEAD
  • git commit --amend
  • git checkout -- .
The correct option is git reset HEAD~1. This command resets the last commit while keeping the changes in the working directory. The HEAD~1 refers to the commit before the last one.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *