You could do this with git filter-branch
. Basically you'd want to:
- Split out the subpath in the first project into a new repository, using the link you've already found.
- Push it to the second project's remote on a unique branch.
Fetch that branch into the second repository, then use git filter-branch
to index-filter it into the correct subdirectory:
git filter-branch --index-filter '
git ls-files -sz |
perl -0pe "s{\t}{\tnewsubdir/}" |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new \
git update-index --clear -z --index-info &&
mv "$GIT_INDEX_FILE.new" "$GIT_INDEX_FILE"
' HEAD
Finally, checkout the master
branch of the second project (or whatever branch you're using), then merge in the newly-filtered branch.
Really not too awful an operation, all told. As AlexanderGladysh notes in the comments, you could also use a subtree merging strategy in the place of steps 3 and 4.