ingydotnet / git-subrepo

MIT License
3.27k stars 270 forks source link

Convert git submodules of the source repository to subrepos #599

Open axk126630 opened 1 year ago

axk126630 commented 1 year ago

I want to clone a Git repository that contains a git submodule. However, when using 'git subrepo clone' to pull in the source repository, the submodule directory remains empty. It appears that 'git subrepo clone' cannot fetch the submodule. Is this a limitation of 'git subrepo clone'? How can I address this, given that including submodules is a common practice in repositories? Is there a way to achieve a similar functionality as 'git clone --recurse-submodules' with 'git subrepo clone'?

admorgan commented 1 year ago

This is a limitation of git subrepo. It was an intentional decision on the part of the designer. submodules were still an experimental item when subrepo was created, and honestly they are still a real pain to work with. Now that submodules are very common I am considering adding a functionality that would bring in the submodules as subrepos. Still a lot of design work to do for this feature and I a lot of work to do before I get it to it, but it is something I would be happy to work out with someone and PRs are always welcome.

axk126630 commented 1 year ago

Thanks @admorgan for your reply. Do you know of any workarounds that involve using 'git subrepo' to clone the repository and also ensure that the submodules from the source repository are included? For example, can we initially clone the repository using the 'git clone --recurse-submodules' then use the 'git subrepo init' in the cloned repository and separately inside its cloned submodules?

admorgan commented 1 year ago

If you are only consuming the repos (you will never git subrepo push) you can manually import the submodules as sub git-subrepos, then delete the .gitmodules file in your local repo. This will tell you when a submodule is updated because you would have to resolve the conflict on a pull that included a submodule update. It is really hackish though.