问题
It seems that if project A has submodules with remote urls, then git clone --recursive A B insists on pulling down copies of each submodule repository from the remote url. Is there a way to get git to clone the submodule repositories from the copies in A instead of pulling from the remote repositories?
I suppose I could do something like:
git clone A B
cd A
git submodule --quiet foreach 'echo [submodule \"$path\"]\\n path = $path\\n url = $toplevel/$path ' > ../B/.gitmodules
cd ../B
git submodule sync
git submodule update --init --recursive
git checkout .gitmodules
cd ..
Is there an easier way?
回答1:
Everything is local?
cp -r A B
[response to comment]
If A is dirty, then:
(cd A; git stash)
cp -r A B
(cd B; git stash drop)
(cd A; git stash apply)
来源:https://stackoverflow.com/questions/9932275/how-can-i-get-git-clone-recursive-a-b-to-use-the-the-submodule-repositories-in