3
remote: Counting objects: 666377, done.
remote: Compressing objects: 100% (150501/150501), done.
Receiving objects: 0% (2171/666377), 756.00 KiB | 119 KiB/s     

my suspiction is that how can compressing the objects, before they are transfered to my pc? this is unbelievalbe, since we must get the files first, then compress it..

so is this a bug of that git output information with the wrong order?

hugemeow
  • 7,777
  • 13
  • 50
  • 63
  • There doesn't appear to be anything wrong with the order. The objects are counted, compressed, and then sent by the remote server so that you can receive them. You may be confusing compression with decompression, which would need to occur after the receive event. –  Aug 20 '12 at 13:34
  • 2
    The objects are compressed on the remote side, not on your PC. – Stefan Aug 20 '12 at 13:38
  • @Stefan so why the files should be compressed before transfer happens, aren't the files store in compressed form on remote git server? if yes, no compress process is needed, i think:) – hugemeow Aug 20 '12 at 13:50

1 Answers1

6

Git tries to reduce the amount of data sent over the (slow) network to your PC, so it compresses the "loose objects" before sending them.

Note that doesn't actually "compress" the files using an archiver like gzip. Instead, it creates an optimal set of patches by looking at the files in the previous 50 changesets. These (binary) patches are the smallest set of bytes which represent the complete state of the system (including all changesets, diffs, commit messages, etc).

This step is a bit expensive (as you will notice when you have a lot of loose objects), so git only does this step when necessary.

Community
  • 1
  • 1
Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • you mean each patch contains 50 changes, why? and how do you know this? – hugemeow Aug 20 '12 at 13:52
  • The technical term for the files which are compressed is "loose objects" - see my edits. 50 refers to the "depth" which Git will search backwards in history to find a similar file (i.e. one which has the least amount of changes). – Aaron Digulla Aug 20 '12 at 14:05