2

There is a fork of micropython, which incorporates lvgl (a gui).

Nearly all lvgl-related code is separate from the micropython code beside some few overlapps.
These overlapps are related to certain (sub-)directories.

Using the lvgl-fork as "ours" and the git repo of micropython as "theirs", I could merge theirs into ours with overwrite (-X) ... and loose the overlapping parts.
Or I could merge without using -X resulting in "thousands" :) of conflicts, which are no real conflicts but updates since the great majority of code of micropython wasn't touched by lvgl.

Since this is a firmware, which is difficult to debug and flashing as such isn't THAT healthy for a flash memory, I don't want to experiment that much... :)

Is there a way to do a kind of a "git merge with forced overwrite except for the following directories, in which I want to get conflicts if there are any"?

RJFalconer
  • 10,890
  • 5
  • 51
  • 66

1 Answers1

0

That does not seem trivial to do, but you might consider:

  • a first merge (-X): you get one commit, but with the overlapping part overriden
  • a second merge between dedicate branches, each one representing the few subfolders you need to pay attention to during said merge.

The idea regarding the latter point is that you can isolate a folder in its own branch using git substree split

Extract a new, synthetic project history from the history of the <prefix> subtree.
The new history includes only the commits (including merges) that affected <prefix>, and each of those commits now has the contents of at the root of the project instead of in a subdirectory.
Thus, the newly created history is suitable for export as a separate git repository.

You can see that approach used in "How do I merge a sub directory in Git?", where you have two branches, but want to merge only the history of dir-1 from branch-a into branch-b.
That is what you want to do in the second step I mention above.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250