如何获得git clone --recursive A B以在A中使用子模块存储库? [英] How can I get git clone --recursive A B to use the submodule repositories in A?

查看:103
本文介绍了如何获得git clone --recursive A B以在A中使用子模块存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎,如果项目A的子模块带有远程URL,则git clone --recursive A B坚持要从远程URL下拉每个子模块存储库的副本.有没有办法让git从A的副本中克隆子模块存储库,而不是从远程存储库中提取子模块存储库?

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 ..

有没有更简单的方法?

推荐答案

一切都是本地的吗?

cp -r A B

[回复评论]

如果A脏了,那么:

   (cd A; git stash)
   cp -r A B
   (cd B; git stash drop)
   (cd A; git stash apply)

这篇关于如何获得git clone --recursive A B以在A中使用子模块存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆