- First unstage the changes from your previous commit by running:
git reset HEAD~
- Now you can edit the files, add them, and commit them again
- 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!