I have successfully been able to convert Submodules to Subdirectories using commands such as the methods outlined in these two examples:
The challenge is to successfully achieve this on a directory, preserving its history through each conversion.
These two methods outlined above have worked fine on a trivial experimental repository, but does not handle a more complex repository. e.g, a repo with an arbitrary commit pattern.
The problem exposes itself when executing
git filter-branch --subdirectory-filter <lib-directory> -- --all
when trying to convert a directory (that was previously a submodule) to a submodule. If I understand correctly. This was throwing:
Rewrite c95281d27e4602e9af50146eefcf7c28f5bb4f35
(2/11)a989b207d3757f9803fd50fa2d77908a4dc1330e
fatal: failed to unpack tree object
c95281d27e4602e9af50146eefcf7c28f5bb4f35:lib/test_submodule
Could not initialize the index`
of which there were absolutely no similar results online.
It was figured this was occurring due to the recurring reference to the submodule within the INDEX, whereby when the submodule was converted, the above error would occur.
Is there some way of performing a filter-branch
that will allow the avoidance of these earlier references to the submodule??
Edit: I've come back looking at this issue again, and I still haven't found a way to solve it. Using the Subdir->Submodule method with git filter-branch
works fine for a normal directory; but crashes when it hits a submodule.
The crash that keeps happening at this section within git:
https://github.com/github/git-msysgit/blob/master/git-filter-branch.sh#L300
I can't make much sense of it though.