First - apologies for asking this question. There are a lot of topics about it already. But I'm not having much luck with them. My lack of familiarity with git is not much help.
I'm moving a folder from one git repo to another (which already exists). e.g.
repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5
repo-2
---- dir1
---- dir2
---- dir3
In the end I want the repos to look like
repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5
repo-2
---- dir1
---- dir2
---- dir3
---- dir-to-move
i.e. For a time dir-to-move will exist in both repos. But eventually I'll migrate the latest changes to repo-2 and remove dir-to-move from repo-1.
My initial research made me believe that I needed to use filter-branch. e.g.
I've since learnt that subtree superseded that approach. However it's not doing what I expected. I thought I'd be able to do something like
In repo-1 workspace
git subtree split -P dir-to-move -b split
to filter the split branch down to only dir-to-move and it's history. Then in repo-2 workspace
git remote add repo-1 repo-1-url.git
git subtree add --prefix dir-to-move split
This does move the code across. It also, sort of, includes the history
e.g.
cd repo-2
git log
Shows commits from repo-1
but
cd repo-2
git log dir-to-move
Shows only an 'Add dir-to-move from commit ....'
i.e. The history is included but does not show up when checked for the specific files/directories.
How can I do this properly?