Search code examples
gitgithubgit-mergegit-pull

Git Partial Fork, synced pull/merge


I want to fork a Git repository A that works with interface X, to my own repository B that works with interface Y.

To do this I would remove X-related files and create my own Y-related files, however I want to be able to pull changes to the core from repository A, in to my repository B, without pulling in X-related files (that I've already removed) and I want to be able to submit changes (i.e. pull request) I've made to the core, without that pull, removing X files from A or adding Y files to A.

From looking through similar questions on this site I've found things like rebasing, and selective merge, I'm not sure if this is actually what I want or not.

My main concern is keeping track of who made what changes, but I also would like to keep the relationship between the to projects if possible.

P.S. both projects are on github, if that provides any extra options


Solution

  • In the situation you describe, you cannot merge between A and B. You could instead create an in-between branch A':

    • Merge A into A' to obtain upstream changes.
    • Commit shared changes to A'.
    • Merge A' into B to apply these changes to your Y-specific code.
    • Commit Y-specific changes to B
    • Never merge B into A'.
    • If you have changes in B that you want to share with A, cherry-pick them into A'.
    • Request pulls to A from A' to share your changes upstream.

    Other possible solutions include supporting both X and Y in both A and B, or splitting X and Y support into separate repositories.