Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion book/08-customizing-git/sections/config.asc
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,15 @@ You can put patterns in your project's `.gitignore` file to have Git not see the

But sometimes you want to ignore certain files for all repositories that you work with.
If your computer is running Mac OS X, you're probably familiar with `.DS_Store` files.
If your preferred editor is Emacs or Vim, you know about files that end with a `~`.
If your preferred editor is Emacs or Vim, you know about files that end with a `~` or `.swp`.

This setting lets you write a kind of global `.gitignore` file.
If you create a `~/.gitignore_global` file with these contents:

[source,ini]
----
*~
.*.swp
.DS_Store
----

Expand Down
4 changes: 2 additions & 2 deletions book/09-git-and-other-scms/sections/import-tfs.asc
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Open the file and find at which characters start and end the column and replace,

[source,powershell]
----
PS> cat AUTHORS_TMP | cut -b 11-20 | tail -n+3 | uniq | sort > AUTHORS
PS> cat AUTHORS_TMP | cut -b 11-20 | tail -n+3 | sort | uniq > AUTHORS
----

The `cut` command keeps only the characters between 11 and 20 from each line.
The `tail` command skips the first two lines, which are field headers and ASCII-art underlines.
The result of all of this is piped to `uniq` to eliminate duplicates, and saved to a file named `AUTHORS`.
The result of all of this is piped to `sort` and `uniq` to eliminate duplicates, and saved to a file named `AUTHORS`.
The next step is manual; in order for git-tfs to make effective use of this file, each line must be in this format:

[source,text]
Expand Down
2 changes: 2 additions & 0 deletions book/10-git-internals/sections/objects.asc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ $ echo 'first commit' | git commit-tree d8329f
fdf4fc3344e67ab068f836878b6c4951e3b15f3d
----

You will get a different hash value because of different creation time and author data.
Replace commit and tag hashes with your own checksums further in this chapter.
Now you can look at your new commit object with `cat-file`:

[source,console]
Expand Down
7 changes: 4 additions & 3 deletions book/10-git-internals/sections/packfiles.asc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ To demonstrate, we'll add the `repo.rb` file from the Grit library – this is a
[source,console]
----
$ curl https://raw.githubusercontent.com/mojombo/grit/master/lib/grit/repo.rb > repo.rb
$ git checkout master
$ git add repo.rb
$ git commit -m 'added repo.rb'
[master 484a592] added repo.rb
Expand Down Expand Up @@ -81,7 +82,7 @@ $ git cat-file -s b042a60ef7dff760008df33cee372b945b6e884e
22054
----

You have two nearly identical 22K objects on your disk.
You have two nearly identical 22K objects on your disk (each compressed to approximately 7K).
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?

It turns out that it can.
Expand Down Expand Up @@ -118,8 +119,8 @@ Because you never added them to any commits, they're considered dangling and are
The other files are your new packfile and an index.
The packfile is a single file containing the contents of all the objects that were removed from your filesystem.
The index is a file that contains offsets into that packfile so you can quickly seek to a specific object.
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.
You've cut your disk usage by by packing your objects.
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.
You've cut your disk usage by ½ by packing your objects.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a record: 2/3 -> 1/2 (Too small to read here)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an intentional change. I've executed all commands in this chapter and measured sum size of all objects. It is 15K, not 22K. Probably author missed the fact that objects are compressed even when stored out of packfile...
I can provide script that executes all commands in this chapter till this line so that anyone can check my data.

@ben, maybe it would be better to just write "by half"?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the web page. It's good, not too small. 😄

image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, "by half" is more idiomatic in English. You'd only use ½ for an exact fraction, and this isn't exact.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've created PR: #535

How does Git do this?
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.
Expand Down