git - How do I delete a commit from a branch? - Stack Overflow

PHOTO EMBED

Tue Sep 13 2022 19:55:31 GMT+0000 (Coordinated Universal Time)

Saved by @dermarmc

git reset --hard HEAD~1
The HEAD~1 means the commit before head.

Or, you could look at the output of git log, find the commit id of the commit you want to back up to, and then do this:

git reset --hard <sha1-commit-id>
 
If you already pushed it, you will need to do a force push to get rid of it...

git push origin HEAD --force
content_copyCOPY

https://stackoverflow.com/questions/1338728/how-do-i-delete-a-commit-from-a-branch