0

In our repository we have two long living branches: main (green) & staging (blue). These do not have a common parent, they are completely unrelated.

What I'm trying to do is branch off of main, do some commits and then merge to staging. enter image description here

What I've done so far is to cherry pick the orange commit into staging. But I'm wondering if I couldn't do it some other way.

I've tried the following:

git checkout staging
git merge feature --allow-unrelated-histories

But this caused chaos, 3000 mismatching files had conflicts, when the orange commit only contained a new file.

  • What problem are you trying to solve? Are you aware that you can [cherry-pick a range of commits](https://stackoverflow.com/questions/1994463/how-to-cherry-pick-a-range-of-commits-and-merge-them-into-another-branch)? – isherwood Oct 27 '21 at 20:41
  • 3
    Having the unrelated histories in the first place is probably the real error; but given that you *do* have unrelated histories, you won't be able to use `git merge` (at least, not usefully here). There are some sneaky tricks one can sometimes pull with `git replace` but it's probably better to just cherry-pick. – torek Oct 27 '21 at 21:13
  • @torek you know what? I dug through the repo log and 5 years ago they did have a common parent. Will try and get the full repo and see if that helps. – Mattias Thalén Oct 28 '21 at 05:35

0 Answers0