How to undo the most recent commit in Git

How to undo the most recent commit in Git
0

#1
  1. First unstage the changes from your previous commit by running:
    git reset HEAD~
  2. Now you can edit the files, add them, and commit them again
  3. If you accidentally pushed the bad commit to a remote repository, you can now overwrite it by running: git push --force origin master

It’s as simple as that!