Our compilation model consists on a super-project with 200 subprojects. My local copy tracks our development (remote) server.
I need to make a clean clone of the super-project but I'm bandwidth limited as to fetch all that info from remote server (last time I did it it took almost 7 hours to complete).
(_Note: the reason why I need a clean copy and not just a new branch on current checked out copy, is because I have to make a huge change in many projects and I want to get rid of all the binary files generated during compilation to be sure the projects are compiling correctly, at the time I don't lose current compilation for normal development).
I've read this similar answer, so I've:
git init new_copy
cd new_copy
git remote add origin file:///c/local_copy
git fetch
git checkout develop
git submodule init
So far everything is OK, but I noticed that submodules were still tracking the remote origin. So, as cited answer mentioned, I'd have to manually change the .gitmodules
file to track the local copy instead. As I said, we have 200 subproject and, in addition, the URL for each submodule repository not necessarily have a pattern, as to make a simple replacement:
Sample of .gitmodules
[submodule "libs/lib1"]
path = libs/lib1
url = https://our-remote-server/library1.git
[submodule "istallers/installer1"]
path = installers/installer1
url = https://our-remote-server/the_first_installer.git
[submodule "installers/installer2"]
path = installers/installer2
url = https://our-remote-server/installer2.git
[submodule "apps/a_great_app"]
path = apps/a_great_app
url = https://our-remote-server/foobar.git
As far I've understood, I have to change the .gitmodules
of the cloned repo to something like this in order to track local copies:
[submodule "libs/lib1"]
path = libs/lib1
url = file:///c/local_copy/libs/lib1
[submodule "istallers/installer1"]
path = installers/installer1
url = file:///c/local_copy/installers/installer1
[submodule "installers/installer2"]
path = installers/installer2
url = file:///c/local_copy/installers/installer2
[submodule "apps/a_great_app"]
path = apps/a_great_app
url = file:///c/local_copy/apps/a_great_app
I only need it for the initial clone, later I can restore the .gitmodules
so it can track the remote origin back again.
Is there any standard / official / easy way to do it or do I have to make a script to generate the new .gitmodules
files?