How can I get git clone --recursive A B to use the the submodule repositories in A?

筅森魡賤 提交于 2020-01-13 14:54:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!