Skip to content

Commit 5773f4c

Browse files
committed
Fix sizes before gc and add change of branch
* We need 'git checkout master' because we've left on 'test' branch in previous section * I was surprised that before gc we had only 22K objects, because we have two copies of 22K files. So I checked it and it appears that because of compression each of them takes only 7K place on disk. Also before compression all objects take 15K if summing them up (not 22K).
1 parent ccb917b commit 5773f4c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

book/10-git-internals/sections/packfiles.asc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ To demonstrate, we'll add the `repo.rb` file from the Grit library – this is a
2626
[source,console]
2727
----
2828
$ curl https://raw.githubusercontent.com/mojombo/grit/master/lib/grit/repo.rb > repo.rb
29+
$ git checkout master
2930
$ git add repo.rb
3031
$ git commit -m 'added repo.rb'
3132
[master 484a592] added repo.rb
@@ -81,7 +82,7 @@ $ git cat-file -s b042a60ef7dff760008df33cee372b945b6e884e
8182
22054
8283
----
8384

84-
You have two nearly identical 22K objects on your disk.
85+
You have two nearly identical 22K objects on your disk (each compressed to approximately 7K).
8586
Wouldn't it be nice if Git could store one of them in full but then the second object only as the delta between it and the first?
8687

8788
It turns out that it can.
@@ -118,8 +119,8 @@ Because you never added them to any commits, they're considered dangling and are
118119
The other files are your new packfile and an index.
119120
The packfile is a single file containing the contents of all the objects that were removed from your filesystem.
120121
The index is a file that contains offsets into that packfile so you can quickly seek to a specific object.
121-
What is cool is that although the objects on disk before you ran the `gc` were collectively about 22K in size, the new packfile is only 7K.
122-
You've cut your disk usage by by packing your objects.
122+
What is cool is that although the objects on disk before you ran the `gc` were collectively about 15K in size, the new packfile is only 7K.
123+
You've cut your disk usage by ½ by packing your objects.
123124

124125
How does Git do this?
125126
When Git packs objects, it looks for files that are named and sized similarly, and stores just the deltas from one version of the file to the next.

0 commit comments

Comments
 (0)