- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我添加了几个 git 子模块,它们在 .gitmodules 中配置。我对子模块的特定提交感兴趣。因此,我提交了这些提交,并且可以在 git submodule status 中看到。说为
[submodule "pcl"]
path = libs/pcl
url = https://github.com/PointCloudLibrary/pcl.git
子模块状态显示 757e28a75a0c6c0413085a2af070670828a48527
libs/pcl。这意味着上面的 SHA1 将在运行 git submodule update --init
但是,我的问题是我不想完全克隆子模块 pcl,因为我只对从 757e28a75a0c6c0413085a2af070670828a48527 开始的提交感兴趣。有没有办法通过在 .gitmodules 文件中写入深度参数等来实现这一点?
我看过几篇文章,但大多数都建议做一个 git add submodule。因为,我已经这样做了,有没有办法为每个子模块编辑带有深度参数的 .gitmodule 文件。
git clone --depth 10 --shallow-submodules <repo>
在我看来会 pull 主分支的 10 次提交,然后 pull 所有子模块的主分支的尖端。我的理解正确吗?
最佳答案
找到了解决该问题的方法,这可能会对其他人有所帮助。
目标是浅克隆子模块。通过执行以下步骤,项目(包括子模块)的大小从 30 GB 减少到 2 GB。该项目由许多不断开发的子模块组成,例如 opencv、ffmpeg、pcl、mrpt 等。
.gitmodule 只包含子模块名称、路径和 url(因此没有花哨的配置选项),就像这样
[submodule "pcl"]
path = libs/pcl
url = https://github.com/PointCloudLibrary/pcl.git
因此,从克隆开始,然后初始化子模块,最后更新子模块。
git clone --depth 10 <repo>
git submodule init
git submodule update --depth 10
如果出现错误 - 错误:服务器不允许请求未通告对象 SHA,请增加此特定模块的深度,例如 100。
git submodule update --depth 100 <submodule> # for those modules, whose depth doesnt match. try with different depths.
成功后,默认继续
git submodule update --depth 10
希望它对某人有帮助,欢迎进一步的解决方案。
关于git clone 浅子模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47798888/
我是一名优秀的程序员,十分优秀!