git 克隆浅层子模块
git clone shallow-submodules
我添加了几个 git 子模块,它们在 .gitmodules 中配置。我对子模块的特定提交感兴趣。因此,我提交了这些提交,并且可以在 git 子模块状态中看到。
说为
[submodule "pcl"]
path = libs/pcl
url = https://github.com/PointCloudLibrary/pcl.git
子模块状态显示757e28a75a0c6c0413085a2af070670828a48527
libs/pcl。
这意味着上面的 SHA1 将在 运行 git submodule update --init
之后被检出
但是,我的问题是我不想完全克隆子模块 pcl,因为我只对从 757e28a75a0c6c0413085a2af070670828a48527 开始的提交感兴趣。有没有办法通过在 .gitmodules 文件中写入深度参数等来实现这一点?
我看过几篇文章,但大多数都建议做一个 git 添加子模块。因为,我已经这样做了,有没有办法,用每个子模块的深度参数编辑 .gitmodule 文件。
git clone --depth 10 --shallow-submodules <repo>
在我看来会拉取 10 个主分支的提交,然后是所有子模块的主分支的尖端。我的理解正确吗?
找到了解决该问题的方法,这可能会对其他人有所帮助。
目标是浅层克隆子模块。通过执行以下步骤,项目(包括子模块)的大小从 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 子模块,它们在 .gitmodules 中配置。我对子模块的特定提交感兴趣。因此,我提交了这些提交,并且可以在 git 子模块状态中看到。 说为
[submodule "pcl"]
path = libs/pcl
url = https://github.com/PointCloudLibrary/pcl.git
子模块状态显示757e28a75a0c6c0413085a2af070670828a48527
libs/pcl。
这意味着上面的 SHA1 将在 运行 git submodule update --init
但是,我的问题是我不想完全克隆子模块 pcl,因为我只对从 757e28a75a0c6c0413085a2af070670828a48527 开始的提交感兴趣。有没有办法通过在 .gitmodules 文件中写入深度参数等来实现这一点?
我看过几篇文章,但大多数都建议做一个 git 添加子模块。因为,我已经这样做了,有没有办法,用每个子模块的深度参数编辑 .gitmodule 文件。
git clone --depth 10 --shallow-submodules <repo>
在我看来会拉取 10 个主分支的提交,然后是所有子模块的主分支的尖端。我的理解正确吗?
找到了解决该问题的方法,这可能会对其他人有所帮助。
目标是浅层克隆子模块。通过执行以下步骤,项目(包括子模块)的大小从 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
希望对某人有所帮助,欢迎进一步的解决方案。