1

I accidentally merged a few commits into the wrong branch (development)

I reverted this via a revert PR, and then merged into the correct branch (Sprint-7)

The team then merged Sprint-7 -> Development -> Sprint-8

Now, Sprint-8 doesn't have my commits from the revert, and when I try to PR from Sprint-7 -> Sprint-8 it shows no differences

I tried to un-un-revert but there's a conflict in our db snapshot so I'm nervous to try it. How else might I resolve this issue?

Joshua Ohana
  • 5,613
  • 12
  • 56
  • 112
  • what is the "revert PR"? is it github or just git? – Serge Dec 29 '19 at 02:48
  • You can try the trick that I outlined in another [answer](https://stackoverflow.com/a/57905240/6868543). But you must be the one who does the merge; you cannot rely on some foreign instance to do it for you. – j6t Dec 29 '19 at 08:08

1 Answers1

1

The problem is that git knows that those two commits were on Development and reverted. Merging Sprint-7 into development will ignore those two commits.

An easy way out is to recreate those two commits as new commits with the same changes and even commit message but not associated by way of cherry-pick etc. An easy way to do this is when on the commit run git reset --soft HEAD^ which will position you to the previous commit with the commit changes you were on staged. Committing that will create a new unrelated but otherwise equal commit. You can cherry-pick commits like this directly onto Development.

karmakaze
  • 34,689
  • 1
  • 30
  • 32