Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

git-push

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), 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. 

Basically the only number above that makes any sense to me is the 8 in "using up to 8 threads", because I have a quad-core processor with hyperthreading, therefore I can run 8 threads.

What are there 22 of? Why does it say 22 and then 14, what happened to the other 8? Why does it say 0 bytes/s, given that it did stuff and took finite time? What is "total" and "delta" and "reused"?

Details about the example: The example above is copy-pasted from Terminal on Mac OS X. I manually did a find-replace to substitute in "myrepo" and "myserver.com", everything else is verbatim. The repository has 910 commits, and I made about 3 commits since the prior push. The 3 new commits affected at least 3 files. The repo contains over a thousand files.

like image 359
SerMetAla Avatar asked Jan 31 '14 09:01

SerMetAla


People also ask

What does git push mean?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.

Does git use delta compression?

Git uses delta compression to efficiently store the objects when it creates pack files. This is an implementation detail about the compression algorithm used -- it's completely immaterial to using git.

What is Delta compression in git?

Delta compression (also called delta encoding, or just delta coding), is where only the differences to a known base file is stored, discarding any similarities. To decompress this, you apply the stored changes (also called “diffs”) to the base file, leaving you with the new file.


2 Answers

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.

like image 181
Alexandre DuBreuil Avatar answered Oct 04 '22 03:10

Alexandre DuBreuil


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.

like image 26
Akash Avatar answered Oct 04 '22 02:10

Akash