'Rebase local commits on remote subtree update

I'm trying to build a monorepo that has subtrees to other projects I'm using. In these subtrees I want to make some customizations to fit my monorepo project.

When changes occur on the remote (original) projects of the subtree I want to pull these changes into my monorepo. And to avoid lots of merge-conflicts instead of merging I would like to rebase my changes onto the updates from remote.

Unfortunately I couldn't find any resource yet that would describe if this is actually possible and how to do this. Also I couldn't yet figure out a solution myself from the git docs.

Here is a diagram of how I imagine the history to be:

History of fileA before and after rebase on repos mono and library



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source