我可以进行“深复制"吗?一个带有子模块的git仓库? [英] Can I make a "deep copy" of a git repository with submodules?
问题描述
克隆整个项目及其所有子模块很容易:
It is easy to clone an entire project plus all its submodules:
git clone --recursive git@github.com:homer/powerplant.git
但是,如何创建一个克隆,将所有这些子模块替换为各个子存储库本身的HEAD?优选地,以这样的方式使得一旦事情改变,这可以容易地重复.目标应该是相同总体代码的只读平面"版本.无需合并.
However, how do I create a clone that has all these submodules replaced by the HEADs of the individual sub-repositories themselves? Preferably in such a way that this can be repeated easy, as soon as something changes. The target should be a read-only "flat" version of the same overall code. No merging should be necessary.
如果可能的话,它将解决我的Launchpad问题,其中bzr
只能导入存储库而没有子模块.
If this is possible, it would solve my Launchpad problems where bzr
can import only repositories without submodules.
推荐答案
如果要从子模块的文件开始而不是git repos,只需执行以下操作:
If you want to start with submodules' files but not as git repos, simply do the following:
- 递归克隆
git clone --recursive git@github.com:homer/powerplant.git
(疯狂的仓库名称btw) - 然后使用
git config --remove-section submodule.name
注销子模块
- clone recursively
git clone --recursive git@github.com:homer/powerplant.git
(insane repo name btw) - then un-register the submodule with
git config --remove-section submodule.name
您将得到所需的结果,即工作树中的子模块文件,但子模块未这样初始化.
You'll end up with what you want, submodule files in the working tree but submodules not initialized as such.
您可能已经使用了最新的git submodule deinit
命令,但是它也会从工作树中删除子模块的文件.
You could have used the newest git submodule deinit
command, but it also removes submodule's files from the working tree.
这篇关于我可以进行“深复制"吗?一个带有子模块的git仓库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!