The general idea is:
- explained in "How to combine two separate unrelated Git repositories into one with single history timeline" (fetch + cherry-picking)
implemented in "Concatenate the history of two Git repositories?"
git clone <git repository B url> cd <git repository B directory> git remote add repo-A-branch <git repository A directory> git fetch repo-A-branch master git remote rm repo-A-branch
Once you have imported the right branch from A, you can use graft point, and then git filter-branch
to turn a grafted history into "real" history, to get rid of the graft point.