当我使用“ git push”时,统计数据是什么意思? (Total,delta,等等)

这里有一个例子:

$ git push -u myserver master
Counting objects: 22, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 1.89 KiB | 0 bytes/s, done.
Total 14 (delta 10), reused 0 (delta 0)
To myserver.com:git/myrepo.git
ed46414..0cae272  master -> master
Branch master set up to track remote branch master from myserver.

基本上上面唯一对我有意义的数字是“使用最多8个线程”中的8,因为我有一个带有超线程的四核处理器,因此我可以运行8个线程。

22个是什么?为什么上面写的是22然后是14另外8个怎么了?为什么它说0字节/s,因为它做了很多事情并且花费了有限的时间?什么是“总”和“三角洲”和“重复使用”?

上面的例子是从 Mac OS X 上的 Terminal 复制粘贴过来的。我手动做了一个 find-place 来替换“ myrepo”和“ myserver.com”,其他的都是一字不差的。存储库有910次提交,自前一次推送以来,我提交了大约3次。3个新的提交至少影响了3个文件。回购包含超过一千个文件。

25163 次浏览

Git is a content addressable file system. i.e., it takes an object(file, tree, commit) and stores it in files addressable by hashes.

Suppose you make a very small change in the file. Should git store the full file as a different object? Well it does. But occasionally(during push, pull), git computes file changes as deltas and store them instead of full files.

That means, the most recent version of file is stored in full (since it should be available most readily), older version of the same file is just an object containing the difference between the two and so on.

This way git saves space while still able to reconstruct the file for any revision you throw at it.

Now coming to your question:

Counting objects: 22, done.: Git is counting the object related to your commits which you are pushing.

Total 14 (delta 10): Git was able to reduce the number of objects by finding 10 deltas.

reused 0 (delta 0): Git can reuse the delta objects if same exists already. For example if the similar changes might have been introduced in some other file, the delta may be similar and reusable. Here, there was nothing to reuse.

Writing objects: 100% (14/14), 1.89 KiB | 0 bytes/s, done. Here Git is sending (or writing) the objects over the network, and you can see progress and speed statistics as it's doing that.

Hope this helps.

Short answer

This is merely the output of the git command git count-objects -v for the push (the same command is called for output when gc, pull and clone). More info in the man pages : git-count-objects(1).

$ git count-objects -v
...
size: 14 # The "Compressing objects: 100% (14/14)" part (the size in KiB)
in-pack: 22 # The "Counting objects: 22" part (the number of objects)
...

Long answer

Counting objects: 22, done.

This is git 22 internal objects being counted for that specific commit. Pretty much everything in git is an object, and are basically blobs saved in your .git/objects folder under their respective hash. More info in the man pages : 9.2 Git Internals - Git Objects.

Compressing objects: 100% (14/14), done.

This is git compressing the objects before send. The 14/14 is the progression in KiB of the compression (14 KiB to compress).

Writing objects: 100% (14/14), 1.89 KiB | 0 bytes/s, done.

This is git sending (if remote) and writing the objects. The 1.89 KiB | 0 bytes/s is the progression in KiB and the speed (0 bytes/s when finished).

Total 14 (delta 10), reused 0 (delta 0)

This is the output of the packfile algorithm in git (see 9.4 Git Internals - Packfiles) and is fairly obscure. It basically packs the unused objects, typically older history, in .git/objects/pack. After packing, git checks if it can reuse packs (hence the reused 0 part). The delta 0 part is the gain in KiB from the packing or from the reuse.