When I do “git push”, what do the statistics mean? (Total, delta, etc.)

后端 未结 2 1730
后悔当初
后悔当初 2020-11-28 03:22

Here is an example:

$ git push -u myserver master
Counting objects: 22, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), don         


        
相关标签:
2条回答
  • 2020-11-28 04:11

    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.

    0 讨论(0)
  • 2020-11-28 04:12

    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.

    0 讨论(0)
提交回复
热议问题