I would like to know how to delete a commit.
By delete
, I mean it is as if I didn\'t make that commit, and when I do a push in the future, my changes wi
If you want to fix up your latest commit, you can undo the commit, and unstage the files in it, by doing:
git reset HEAD~1
This will return your repository to its state before the git add commands that staged the files. Your changes will be in your working directory. HEAD~1 refers to the commit below the current tip of the branch.
If you want to uncommit N commits, but keep the code changes in your working directory:
git reset HEAD~N
If you want to get rid of your latest commit, and do not want to keep the code changes, you can do a "hard" reset.
git reset --hard HEAD~1
Likewise, if you want to discard the last N commits, and do not want to keep the code changes:
git reset --hard HEAD~N