I have made a mistake in one of the commits. Now I want to completely delete this commit, so it looks like it has never existed. I don't want to see this in log.
I have tried all tips from this question ("How to delete a 'git commit'"), but I can see the commit in the log. How I can completely delete it?
-- Edit --
Ok, I do not give the completely information. Kevin Ballard are correct.
By now, I do not push this commit, it's only in my machine. The ouah answer work, the command
git log
will not show, but what the command
git reset --hard HEAD^
do is "chekout last commit and change the the branch to this", so I continue seeing that commit with a graph program like SmartGit.
--Edit 2--
No, this is a SmartGit bug!!!! The commit really disappear. I have to close the windows of log and than open again. The commit is no more there.
If it is the last commit
git reset --hard HEAD^
if it is not the last commit
git rebase -i commit_hash^
an editor will open, delete the whole line with the commit, save and quit.
Note that rewriting history or rebasing if the branch has already been pushed is usually a bad idea and you may prefer to use
git revert commit_hash
that will add a new commit that reverts the commit commit_hash
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With