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 will not push to the remote branch.
I read git help, and I think the command I should use is git reset --hard HEAD
. Is this correct?
To delete in local branch, use
To delete in a remote branch, use
If you've already pushed, first find the commit you want to be at HEAD ($GIT_COMMIT_HASH_HERE), then run the following:
Then each place the repo has been cloned, run:
Source: https://gist.github.com/sagarjethi/c07723b2f4fa74ad8bdf229166cf79d8
Delete the last commit
For example your last commit
git push origin +aa61ab32^:master
Now you want to delete this commit then an Easy way to do this following
Steps
First reset the branch to the parent of the current commit
Force-push it to the remote.
For particular commit, you want to reset is following