Reverting to previous MR and incorporating from select future commits already in main branch

Viewed 26

Some dependencies we merged into our main are now proving to have many downstream impacts.

At this point, the MR that updated these dependencies is previous to several newer MRs.

So if I have MR's as such:

336!
337!
338!

I need to revert to 336! merge in 338!.

Proposed Solution I think I will create a bugfix branch that is an initial pull from 336!. Then I will merge 338! into my new bugfix branch. Test it of course, and then Merge this branch into the master.

This will inherently overwrite the changes that were made in 337!? Or will merging in 338! merge in 337! changes as well?

1 Answers

Another option would be to revert 337 in a bugfix branch created from main.

Initially, that bugfix branch includes all main history, including your 3 MRs.

But, by reverting 337!, you would:

  • add a new commit cancelling 337 changes
  • keep 336 and 338
  • resolve in that branch any merge conflicts and test if everything still work.

So:

git switch -c bugfix main
git revert <3371 merge commit>
# test
git switch main
git merge --no-ff bugfix

Then you merge bugfix to main.

Related