2021年3月7日星期日

How to squash duplicate commits due to an incorrect rebase?

I have a kinda specific, complex Git situation due to mistakes I made early on and didn't address at that time. I'll first explain the steps I took (with Git network visuals) to get to where I am.

  1. I started with an initial master branch.

step-1

  1. I created a new-catalog branch and made set of commits A.

step-2

  1. I rebased new-catalog with outdated local master and pulled into the new rebased new-catalog branch. (Although I didn't know it at the time, this would be the start of my misery)

step-3

This created a second set of commits A' identical to A but with different commits with new timestamps.

step-3-context

  1. I created a beta/master branch (still off the outdated local master), and PRed new-catalog into beta/master.

step-4

  1. I made another set of commits B on beta/master.

step-5

  1. I made a sub branch beta/bootstrap off of beta/master.

step-6

Now, that I am here, I want to rebase beta/master with master to prepare to PR back into master. I did try rebasing, however, I am getting some weird conflicts that I suspect is due to the duplicate set of commits A and A'. What is the safest way to rebase beta/master with master?

I have considered doing an interactive rebase and squashing/dropping the initial set of commits A, but I also don't want to lose the time information of those commits. If this is the best option, I am willing to lose the time information, but I just wanted to see if there was a better way.

In addition, if I am able to rebase beta/master successfully, do I need to rebase beta/bootstrap as well? Or will I just be able to PR into beta/master without any conflicts?

I made a git-practice repository to recreate these mistakes and this is the whole network.

Thank you so much!

https://stackoverflow.com/questions/66502211/how-to-squash-duplicate-commits-due-to-an-incorrect-rebase March 06, 2021 at 11:56AM

没有评论:

发表评论