Update current git fork of a project with original project with merge strategy depending on directory

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.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top