Duplicate commits, clean up commit history

This is not a mission critical issue. But, I made a mess out of a development branch. I checked out a new branch from another non-master branch. I renamed the new branch because of an sdk update. Merged in individual commits…I want to clean up the log. Eventually, the dev branch will become master.

  • I want to get rid of commit f600e3a which somehow is a duplicate of 5519b25
  • And I would like to know how to do the opposite of the above. Get rid of 5519b25
  • I want to get rid of the two Merge messages 8e42420 and 3332687
 168d84a 2021-07-25  (origin/lzma-sdk-21.02, lzma-sdk-21.02) 
 f600e3a 2021-07-25  Fix if (!(TEST_ONLY | STDOUT)) typo in
 5ffca4a 2021-07-25  Use Cipher Text Stealing mode for enc
 5b958d2 2021-07-25  Remove unused function definition lr
 5519b25 2021-07-25  Fix if (!(TEST_ONLY | STDOUT)) typo in 
 a69389b 2021-07-23  (tag: v0.7.99) Bitcoin SCRYPT key deri
 8e42420 2021-07-23  Merge commit '9e646ea' into 21.02dev
 3332687 2021-07-23  Merge commit '9e646ea' into lzma-sdk-21
 9e646ea 2021-07-23  Catch bad password in get_fileinfo() fo

This is a mess of my own making. Since I am a solo developer, I use a mix of merge, git checkout file, patches to move changes between branches. That’s why the mess above.

Appreciate suggestions. Thank you. lrzip-next beta branch

In principle, this can all be done with an interactive rebase: You can delete, reorder, or change commits. You can find a detailed description here: Git - Rewriting History

Note that depending on the details messing with the order of commits can lead to conflicts, e.g. if you delete a duplicate commit and then one of the commits after doesn’t fit right.

Thanks again. The two FIX commits are identical and contain one file and one line of change. The merge messages appear empty. I forgot to use --no-ff --no-commit. I’ll backup first :wink:

1 Like

So I decided to ignore any mess in temporary or dev branches. I can just copy over the needed files or do a very selective merge. There are some forks out there and I don’t want to mess downstream up.