Search code examples
gitgit-push

Delete Commit in git History


How can delete one duplicate commit in Git ? I cannot push because I get the error:

error : duplicate commit

I can't seem to be able to delete this commit.


Solution

  • If $br is empty, the checkout cmd creates a branch whose name is 95196f3b7ac656803cd4ed703d6d06b15e527e40 which points to HEAD. However it's also the name of a git object, the commit 95196f3b7ac656803cd4ed703d6d06b15e527e40. When you run git show 95196f3b7ac656803cd4ed703d6d06b15e527e40, git does not know to show HEAD or the true 95196f3b7ac656803cd4ed703d6d06b15e527e40. So it's ambitious.