Which command undoes the last commit but keeps the changes in the working directory?

  1. git revert HEAD
  2. git reset --soft HEAD~1
  3. git reset --hard HEAD~1
  4. git delete HEAD~1

Explanation

git reset --soft HEAD~1 moves the HEAD pointer back one commit but keeps the changes in the staging area, allowing you to modify and recommit them.