I had the following git repositories
- repoA
- repoB
- repoC
which I combined into
- repoAll where each repo was moved into a subdir
so this looks like
- repoAll
- dirA
- dirB
- dirC
I have followed the instructions on http://jasonkarns.com/blog/merge-two-git-repositories-into-one/ to make this happen. Which essentially means
git remote add -f repoA /path/to/repoA
git merge -s ours --no-commit repoA/master
git read-tree --prefix=dirA/ -u repoA/master
git ci -m "merging repoA into dirA"
...
So now however the history for the files is no longer connected since
git log --follow dirA/pom.xml
shows nothing.
However,
git log --follow pom.xml
does show the correct (old) history for that file. This is not really good enough since no tool such as eclipse or other git clients will be able to show the full history.
To make matters worse, there have been already new commits on the combined repo so doing the merge again is not really an option (I now know that I should have moved repoA/*
into repoA/dirA
before doing the merge).
I have thought about inserting a commit that would do the move before the initial merge on repoAll but that would require me to rebase all the changes (which are now a 100+) and resolve the changes.
The question/solution Git log shows very little after doing a read-tree merge and How can I rewrite history so that all files, except the ones I already moved, are in a subdirectory? seem to only work for the whole repository, not for a specific subdir (or at least not if you have already new commits on repoAll).
I think that there should be some way to rewrite the history of a specific subdir (such as dirA) but I cannot seem to figure out how.