Git 2.18(Q2 2018)可能通过改进git submodule update
来避免该错误,该错误会影响git submodule pull
。
"git submodule update
"尝试针对上游存储库执行两种不同类型的"git fetch
",以获取绑定在子模块路径上的提交,但如果第一种类型(即普通获取)失败,则会错误地放弃,从而使第二种“最后手段”(即按对象名称获取确切提交对象)无效。
这已得到纠正。
查看 提交 e30d833(2018年5月15日)由Stefan Beller(stefanbeller
)提供。
(由Junio C Hamano -- gitster
--在提交 a173ddd中合并,2018年5月30日)
git-submodule.sh
:更努力地获取子模块
This is the logical continuum of fb43e31 (submodule: try harder to
fetch needed sha1 by direct fetching sha1, 2016-02-23, Git 2.8.0) and fixes it as some assumptions were not correct.
The commit states:
If $sha1
was not part of the default fetch ... fail ourselves here assumes that the fetch_in_submodule
only fails when the serverside does not support fetching by sha1.
There are other failures, why such a fetch may fail, such as
fatal: Couldn't find remote ref HEAD
which can happen if the remote side doesn't advertise HEAD and we do not
have a local fetch refspec.
Not advertising HEAD is allowed by the protocol spec and would happen,
if HEAD points at an unborn branch for example.
Not having a local fetch refspec can happen when submodules are fetched
shallowly, as then git-clone doesn't setup a fetch refspec.
So do try even harder for a submodule by ignoring the exit code of the
first fetch and rather relying on the following is_tip_reachable
to
see if we try fetching again.
注意:Git 2.22(2019年第二季度)已经改进了子模块获取错误信息。
请参见提交记录bd5e567(2019年3月13日),作者为Jonathan Tan(jhowtan
)。
(由Junio C Hamano -- gitster
--于提交记录32414ce中合并,2019年4月9日)
子模块:清晰地解释第一次尝试失败的原因
When cloning with --recurse-submodules
a superproject with at least one
submodule with HEAD pointing to an unborn branch, the clone goes
something like this:
Cloning into 'test'...
<messages about cloning of superproject>
Submodule '<name>' (<uri>) registered for path '<submodule path>'
Cloning into '<submodule path>'...
fatal: Couldn't find remote ref HEAD
Unable to fetch in submodule path '<submodule path>'
<messages about fetching with SHA-1>
From <uri>
* branch <hash> -> FETCH_HEAD
Submodule path '<submodule path>': checked out '<hash>'
In other words, first, a fetch is done with no hash arguments (that is,
a fetch of HEAD) resulting in a "Couldn't find remote ref HEAD
" error;
then, a fetch is done given a hash, which succeeds.
This commit improves the notice to be clearer that we are retrying the
fetch, and that the previous messages (in particular, the fatal errors
from fetch) do not necessarily indicate that the whole command fails.
请注意,使用 Git 2.34(2021 年第四季度),
git submodule
(man) 的部分重新实现将继续使用 C 语言。
请查看 提交 c51f8f9(2021年8月24日),作者为 Atharva Raykar (tfidfwastaken
)。
(由Junio C Hamano -- gitster
--于提交 e78db9d中合并,2021年9月20日)
指导者:Christian Couder
指导者:Shourya Shukla
签署者:Atharva Raykar
添加一个新的子模块--辅助程序子命令 run-update-procedure
,如果子模块的 SHA1 值与超级项目预期的不匹配,则运行更新过程。
这意味着上述提到的 is_tip_reachable
Shell 方法已不再存在。
同样的重写在 Git 2.36 (2022 年第二季度) 中继续进行,和 "git submodule update
"(man)。
请查看 提交 c9d2562, 提交 104744f, 提交 97cb977, 提交 29a5e9e, 提交 1012a5c, 提交 e441966, 提交 1a0b78c, 提交 f7bdb32 (2022年3月4日) 由 Glen Choo (chooglen
) 提交。
请查看 提交 3ce52cb, 提交 5312a85, 提交 a77c3fc (2022年3月4日) 由 Atharva Raykar (tfidfwastaken
) 提交。
请查看 提交 ed9c848, 提交 aca8568 (2022年3月4日) 由 Ævar Arnfjörð Bjarmason (avar
) 提交。
(由 Junio C Hamano -- gitster
-- 合并于 提交 7649bfb, 2022年3月23日)
随着 Git 2.39(2022 年第四季度)的更新,重写工作正在继续进行,其中包括准备删除 git-submodule.sh
并用内置替换它。
请查看 提交记录 69d9446, 提交记录 1b6e200, 提交记录 64f48ad, 提交记录 82ff877, 提交记录 46e87b5, 提交记录 d50d848, 提交记录 435285b, 提交记录 44874cb, 提交记录 cc74a4a (2022年11月08日) 作者为 Ævar Arnfjörð Bjarmason (avar
).
(由Junio C Hamano -- gitster
--合并于提交记录1107a39, 2022年11月23日)
git submodule foreach ...
在子仓库中的一个错误发生时停止,请将||:
添加到命令中,例如git submodule foreach 'git pull origin master || :'
。 - Stefan Näwe