edit: oops. I read the question exactly backwards, my apologies. You're trying to bring the sliced myproject
history from repo A, plus any later additions, back in to repo B, not the other way around.
Fetch the repoB history back into your repoA repository as-is. Find the tips you sliced originally and the commits you sliced them from, checking tree id's will do it if you can't eyeball it from commit messages or other records. Graft those they-were-tips-when-you-sliced-them commits onto the commits they were sliced from, then merging the current tips with the subtree
option git merge -Xsubtree repoB/branchnamehere
will work normally.
So to find the oldest commit that has any particular set of content at content/themes/myproject
, and the content id,
git log --pretty='%H:content/themes/myproject %H' --branches --tags \
-- content/themes/myproject \
| git cat-file --batch-check='%(rest) %(objectname)'
will list the id of all the commits that touched that directory and the id of the content each committed there. After fetching repoB's current history you can list each commit and its committed tree id more simply,
git log repoB/branch --pretty=%H\ %T
and match up tree id's from there.
git replace --graft repoBcommit-with-tree-T repoAcommit-with-that-tree-too
and now the repo B history since that commit will appear locally to have branched off the repoA history there (but taken only that subdirectory). Then
git merge -Xsubtree repoBbranch-with-that-commit
and you can run an ancestry-only git filter-branch -- --all
first to bake in the grafts either before or after that merge so the results are easier to understand when fetched elsewhere.