Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I delete a merge commit?

I have done some mess in my repo, which I don’t understand at all.

A strange commit has appeared:

commit 70cc4bd585019286ef64ef591f1b6ab310484eb3 (HEAD, origin/master,
origin/HEAD, master) Merge: 960b06a 709f964 Author: DuchSuvaa
bga.sowa@gmail.com Date: Tue Sep 12 15:46:05 2023 +0200

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Merge branch 'master' of https://github.com/DuchSuvaa/monitor-kolejek

I don’t really understand how that happened. Someone told me that git reset –hard HEAD~1 will do the job but when I do it, I am checkouted to the third (!) commit from the end and nothing is removed from GitHub.

How do I remove that problematic merge commit from my repo on Github?

>Solution :

  1. git log --oneline
  2. Copy the commit hash before merge one.
  3. git reset --hard <copied-commit-hash>
  4. git push --force (be carefully, it rewrites the remote history)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading