Git 克隆“检查连接性” - 它是什么?

Kar*_*aru 14 git

git clone通过 SSH 或 HTTP 执行存储库时,您会得到如下所示的输出:

Cloning into 'some_directory'...
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (7/7), done.
Checking connectivity... done.
Run Code Online (Sandbox Code Playgroud)

我对最后一个“检查连接”步骤感兴趣。它发生repo 及其所有元数据已下载之后,即在任何 Internet 连接完成之后。

该过程的这一步究竟完成了什么?

ge0*_*rdi 19

我认为这个词connectivity与这里的网络连接无关。在从 git 服务器接收到所有数据后显示该消息。

可以在 git 源码中找到一些线索。connected.c文件中有以下注释:

/*
 * If we feed all the commits we want to verify to this command
 *
 *  $ git rev-list --objects --stdin --not --all
 *
 * and if it does not error out, that means everything reachable from
 * these commits locally exists and is connected to our existing refs.
 * Note that this does _not_ validate the individual objects.
 *
 * Returns 0 if everything is connected, non-zero otherwise.
 */
Run Code Online (Sandbox Code Playgroud)

它与显示消息check_everything_connected_real后调用的函数有关。Checking connectivity...

所以它基本上意味着 git 正在检查是否所有对象都被正确接收(连接到现有的引用)。