8

I want to check the total size of a git repository. Is funny that du is giving me two different kind of sizes when the -h flag is sent. It is actually giving double size.

Why is this? What is the correct size?

MyMac:~/repositories/my-repo.git davidrod$ du -h
  0B    ./branches
 64K    ./hooks
4.0K    ./info
  0B    ./objects/info
3.3M    ./objects/pack
3.3M    ./objects
4.0K    ./refs/heads
8.0K    ./refs/tags
 12K    ./refs
3.3M    .
MyMac:~/repositories/my-repo.git davidrod$ du 
0   ./branches
128 ./hooks
8   ./info
0   ./objects/info
6672    ./objects/pack
6672    ./objects
8   ./refs/heads
16  ./refs/tags
24  ./refs
6856    .
Manavalan Gajapathy
  • 3,900
  • 2
  • 20
  • 43
David Rz Ayala
  • 2,165
  • 1
  • 20
  • 22

2 Answers2

9

The size on OSX (which I assume you have from the computer name) is calculated on 512-byte blocks because the BSD version of du is used (other versions, like the Cygwin's one I am using now on Windows, behave differently).

So for every 1K you get two blocks, apparently doubling the value of every size.

Cranio
  • 9,647
  • 4
  • 35
  • 55
4

They're both correct. In the second case, the unit is blocks (512B each). 1 kilobyte = 2 blocks.

that other guy
  • 116,971
  • 11
  • 170
  • 194