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

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

问题描述

看起来,如果项目A具有远程URL的子模块,那么 git clone --recursive A B 坚持从远程URL下拉每个子模块存储库的副本。有没有办法让git从A副本中复制子模块存储库,而不是从远程存储库中提取?

我想我可以这样做:

p>

  git clone AB 
cd A
git子模块--quiet foreach'echo [submodule \$ path \] \\ path = $ path \\ url = $ toplevel / $ path'> ../B/.gitmodules
cd ../B
git子模块sync
git子模块更新--init --recursive
git checkout .gitmodules
cd。 。

有没有更简单的方法?

解决方案

一切都是本地的?

  cp -r AB 


$ b $ p
$ b $ p如果A很脏,那么: / b>

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


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?

解决方案

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)

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

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