Which command is used to undo a commit that has not been pushed to the remote repository?

  • git reset --soft HEAD^
  • git revert HEAD
  • git reset --hard HEAD^
  • git reset HEAD^
The correct option, git reset --hard HEAD^, is used to undo the last commit completely. It discards changes and moves the HEAD pointer to the previous commit. git reset --soft HEAD^ preserves changes, git revert HEAD creates a new commit to undo changes, and git reset HEAD^ is for unstaging.
Add your answer
Loading...

Leave a comment

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