Skip to content

Commit 63df61a

Browse files
committed
Merge commit 'cok/book' into book
2 parents a5f85ba + ca28040 commit 63df61a

File tree

14 files changed

+115
-113
lines changed

14 files changed

+115
-113
lines changed

text/01_Introduction/0_ Introduction.markdown

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ minutes to read through.
1818
Next we will go over **Intermediate Git Usage** - things that are slightly more
1919
complex, but may replace some of the basic commands you learned in the first
2020
section. This will mostly be tricks and commands that will feel more
21-
comforatble after you know the basic commands.
21+
comfortable after you know the basic commands.
2222

2323
After you have all of that mastered, we will cover **Advanced Git** - commands
2424
that most people probably don't use very often, but can be very helpful in
2525
certain situations. Learning these commands should round out your day-to-day
26-
git knowledge, you will be a master of the Git.
26+
git knowledge; you will be a master of the Git!
2727

2828
Now that you know Git, we will then cover **Working with Git**. Here we will go
2929
over how to use Git in scripts, with deployment tools, with editors and more.
30-
These sections are meant to help you integrate Git into your environement.
30+
These sections are meant to help you integrate Git into your environment.
3131

3232
Lastly, we will have a series of articles on **low-level documentation** that may
3333
help the Git hackers who want to learn how the actual internals and protocols

text/02_Git_Object_Db_Basics/0_ Git_Object_Db_Basics.markdown

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ looks something like this:
1111
You will see these 40-character strings all over the place in Git.
1212
In each case the name is calculated by taking the SHA1 hash of the
1313
contents of the object. The SHA1 hash is a cryptographic hash function.
14-
What that means to us is that it is impossible to find two different
14+
What that means to us is that it is virtually impossible to find two different
1515
objects with the same name. This has a number of advantages; among
1616
others:
1717

@@ -32,7 +32,7 @@ type of object it is, and there are four different types of objects:
3232

3333
- A **"blob"** is used to store file data - it is generally a file.
3434
- A **"tree"** is basically like a directory - it references a bunch of
35-
other trees and/or blobs (ie. files and sub-directories)
35+
other trees and/or blobs (i.e. files and sub-directories)
3636
- A **"commit"** points to a single tree, marking it as what the project
3737
looked like at a certain point in time. It contains meta-information
3838
about that point in time, such as a timestamp, the author of the changes
@@ -42,14 +42,14 @@ type of object it is, and there are four different types of objects:
4242
along those lines.
4343

4444
Almost all of Git is built around manipulating this simple structure of four
45-
different object types. It is sort of it's own little filesystem that sits
46-
on top of your filesystem.
45+
different object types. It is sort of its own little filesystem that sits
46+
on top of your machine's filesystem.
4747

4848
### Different from SVN ###
4949

5050
It is important to note that this is very different from most SCM systems
51-
that you are probably used to. Subversion, CVS, Perforce, Mercurial and the like all
52-
use _Delta Storage_ systems - they store the differences between one commit
53-
and the next. Git does not do this - it stores a snapshot of what all the
54-
files in your project look like each time you commit in this tree structure. This
55-
is a very important concept to understand when using Git.
51+
that you may be familiar with. Subversion, CVS, Perforce, Mercurial and the
52+
like all use _Delta Storage_ systems - they store the differences between one
53+
commit and the next. Git does not do this - it stores a snapshot of what all
54+
the files in your project look like in this tree structure each time you
55+
commit. This is a very important concept to understand when using Git.

text/02_Git_Object_Db_Basics/1_Trees_and_Blobs.markdown

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A blob generally stores the contents of a file.
55
[fig:object-blob]
66

77
You can use linkgit:git-show[1] to examine the contents of any blob.
8-
Assuming we have a SHA for a blob, we can examine its contents like this:
8+
Assuming we have the SHA for a blob, we can examine its contents like this:
99

1010
$ git show 6ff87c4664
1111

@@ -14,7 +14,7 @@ Assuming we have a SHA for a blob, we can examine its contents like this:
1414
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
1515
...
1616

17-
A "blob" object is nothing but a binary blob of data. It doesn't refer
17+
A "blob" object is nothing but a chunk of binary data. It doesn't refer
1818
to anything else or have attributes of any kind, not even a file name.
1919

2020
Since the blob is entirely defined by its data, if two files in a
@@ -32,7 +32,7 @@ trees - it generally represents the contents of a directory or subdirectory.
3232

3333
The ever-versatile linkgit:git-show[1] command can also be used to
3434
examine tree objects, but linkgit:git-ls-tree[1] will give you more
35-
details. Assuming we have a SHA for a tree, we can examine it like this:
35+
details. Assuming we have the SHA for a tree, we can examine it like this:
3636

3737
$ git ls-tree fb3a8bdd0ce
3838
100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c .gitignore
@@ -49,14 +49,13 @@ As you can see, a tree object contains a list of entries, each with a
4949
mode, object type, SHA1 name, and name, sorted by name. It represents
5050
the contents of a single directory tree.
5151

52-
The object type may be a blob, representing the contents of a file, or
53-
another tree, representing the contents of a subdirectory. Since trees
54-
and blobs, like all other objects, are named by the SHA1 hash of their
55-
contents, two trees have the same SHA1 name if and only if their
56-
contents (including, recursively, the contents of all subdirectories)
57-
are identical. This allows git to quickly determine the differences
58-
between two related tree objects, since it can ignore any entries with
59-
identical object names.
52+
An object referenced by a tree may be blob, representing the contents of a
53+
file, or another tree, representing the contents of a subdirectory. Since
54+
trees and blobs, like all other objects, are named by the SHA1 hash of their
55+
contents, two trees have the same SHA1 name if and only if their contents
56+
(including, recursively, the contents of all subdirectories) are identical.
57+
This allows git to quickly determine the differences between two related tree
58+
objects, since it can ignore any entries with identical object names.
6059

6160
(Note: in the presence of submodules, trees may also have commits as
6261
entries. See the **Submodules** section.)

text/02_Git_Object_Db_Basics/2_Commits.markdown

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ As you can see, a commit is defined by:
3434
- an **author**: The name of the person responsible for this change, together
3535
with its date.
3636
- a **committer**: The name of the person who actually created the commit,
37-
with the date it was done. This may be different from the author, for
38-
example, if the author was someone who wrote a patch and emailed it
39-
to the person who used it to create the commit.
37+
with the date it was done. This may be different from the author; for
38+
example, if the author wrote a patch and emailed it to another person who
39+
used the patch to create the commit.
4040
- a **comment** describing this commit.
4141

4242
Note that a commit does not itself contain any information about what
@@ -53,7 +53,7 @@ taken from the content currently stored in the index.
5353

5454
### The Object Model ###
5555

56-
So, now that we've looked at the 3 main object types (the blob, tree and commit),
56+
So, now that we've looked at the 3 main object types (blob, tree and commit),
5757
let's take a quick look at how they all fit together.
5858

5959
If we had a simple project with the following directory structure:

text/02_Git_Object_Db_Basics/3_Trust_and_Tags.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33

44
[fig:object-tag]
55

6-
A tag object contains an object, object type, tag name, the name of the
7-
person ("tagger") who created the tag, and a message, which may contain
8-
a signature, as can be seen using linkgit:git-cat-file[1]:
6+
A tag object contains an object name (called simply 'object'), object type,
7+
tag name, the name of the person ("tagger") who created the tag, and a
8+
message, which may contain a signature, as can be seen using
9+
linkgit:git-cat-file[1]:
910

1011
$ git cat-file tag v1.5.0
1112
object 437b1b20df4b356c9342dac8d38849f24ef44f27

text/02a_Git_Directory_and_Working_Directory/0_ Git_Directory_and_Working_Directory.markdown

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
### The Git Directory ###
44

5-
The 'git directory' is the directory that stores all the Git meta information
6-
about your project - including all of the objects (commits, trees, blobs, tags),
7-
all of the pointers to where different branches are and more.
5+
The 'git directory' is the directory that stores all Git's history and meta
6+
information for your project - including all of the objects (commits, trees,
7+
blobs, tags), all of the pointers to where different branches are and more.
88

9-
There is only one Git Directory per project (as opposed to one per subdirectory like SVN or CVS),
10-
and that directory is (by default, though not neccesarily) found in the '.git'
11-
directory in the root of your project. If you look at the contents of that
12-
directory, you can see all of our important files:
9+
There is only one Git Directory per project (as opposed to one per
10+
subdirectory like with SVN or CVS), and that directory is (by default, though
11+
not necessarily) '.git' in the root of your project. If you look at the
12+
contents of that directory, you can see all of your important files:
1313

1414
$>tree -L 1
1515
.
@@ -29,6 +29,6 @@ directory, you can see all of our important files:
2929
The Git 'working directory' is the directory that holds the current checkout
3030
of the files you are working on. Files in this directory are often removed
3131
or replaced by Git as you switch branches - this is normal. All your history
32-
is stored in the Git Directory, the working directory is simply a temporary
32+
is stored in the Git Directory; the working directory is simply a temporary
3333
checkout place where you can modify the files until your next commit.
3434

text/03_The_Git_Index/0_ The_Git_Index.markdown

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
The Git index is used as a staging area between your working directory
44
and your repository. You can use the index to build up a set of changes
5-
that you want to commit together relatively easily. When you create a commit,
6-
what is committed is what is currently in the index, not what is in your working
7-
directory.
5+
that you want to commit together. When you create a commit, what is committed
6+
is what is currently in the index, not what is in your working directory.
87

98
### Looking at the Index ###
109

1110
The easiest way to see what is in the index is with the linkgit:git-status[1]
12-
command. When you run the status, you can see what files are staged (currently in your index),
13-
which are modified but not yet staged, and which are completely untracked.
11+
command. When you run git status, you can see which files are staged
12+
(currently in your index), which are modified but not yet staged, and which
13+
are completely untracked.
1414

1515
$>git status
1616
# On branch master
@@ -40,5 +40,5 @@ information as long as you have the name of the tree that it described.
4040
And with that, you should have a pretty good understanding of the basics of
4141
what Git is doing behind the scenes, and why it is a bit different than most
4242
other SCM systems. Don't worry if you don't totally understand it all right
43-
now, we'll revisit all of these topics in the next sections. Now we're ready
43+
now; we'll revisit all of these topics in the next sections. Now we're ready
4444
to move on to installing, configuring and using Git.

text/05_Installing_Git/3_Mac_105.markdown

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
### Mac 10.5 ###
22

3-
With Leopard, you can also install via MacPorts, but you also have the option of
4-
using a nice installer, which you can download from here :
5-
[Git OSX Installer](http://code.google.com/p/git-osx-installer/downloads/list?can=3)
3+
With Leopard, you can also install via MacPorts, but here you have the
4+
additional option of using a nice installer, which you can download from here:
5+
[Git OSX
6+
Installer](http://code.google.com/p/git-osx-installer/downloads/list?can=3)
67

78
If you prefer to install it from source, these guides may be particularly helpful to you :
89

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
### Git Config ###
22

3-
The first thing you're going to want to do is to setup your name and
4-
email address for Git to use to sign your commits.
3+
The first thing you're going to want to do is set up your name and email
4+
address for Git to use to sign your commits.
55

66
$ git config --global user.name "Scott Chacon"
77
$ git config --global user.email "schacon@gmail.com"
88

9-
That will setup a file in your home directory that stores your name and email
10-
in any Git project where it's not overridden. By default that file is *~/.gitconfig*
11-
and the contents will then look like this:
9+
That will set up a file in your home directory which may be used by any of
10+
your projects. By default that file is *~/.gitconfig* and the contents will
11+
look like this:
1212

1313
[user]
1414
name = Scott Chacon
1515
email = schacon@gmail.com
1616
17-
If you want to override those values for a specific project (change to using a
18-
work email address, for example), you can run the *git config* command without
19-
the *--global* option while in that project.
17+
If you want to override those values for a specific project (to use a work
18+
email address, for example), you can run the *git config* command without the
19+
*--global* option while in that project. This will add a [user] section like
20+
the one shown above to the *.git/config* file in your project's root
21+
directory.

text/06a_Getting_A_Repo/1_Getting_a_Git_Repo.markdown

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,41 @@
11
## Getting a Git Repository ##
22

3-
So now that we're all setup, we need a Git repository. We can do this one of
3+
So now that we're all set up, we need a Git repository. We can do this one of
44
two ways - we can *clone* one that already exists, or we can *initialize* one
5-
either from existing files that aren't in source control yet, or just create
6-
a new project.
5+
either from existing files that aren't in source control yet, or from an empty
6+
directory.
77

88
### Cloning a Repository ###
99

10-
In order to get a copy of a project, you will need to know the projects Git
11-
URL - the location of the repository. Git can operate over many different
12-
protocols, so it may begin with ssh://, http(s):// or git://, or just a username,
13-
in which case it will assume ssh. Some repositories have more than one way to
14-
clone it. For example, the source code to Git itself can be cloned either through
15-
the git:// protocol:
10+
In order to get a copy of a project, you will need to know the project's Git
11+
URL - the location of the repository. Git can operate over many different
12+
protocols, so it may begin with ssh://, http(s)://, git://, or just a username
13+
(in which case git will assume ssh). Some repositories may be accessed over
14+
more than one protocol. For example, the source code to Git itself can be
15+
cloned either over the git:// protocol:
1616

1717
git clone git://git.kernel.org/pub/scm/git/git.git
1818

1919
or over http:
2020

2121
git clone http://www.kernel.org/pub/scm/git/git.git
2222

23-
The git:// protocol is faster and more efficient, but sometimes it is necessary
24-
to use the simpler http based one behind corporate firewalls or what have you.
25-
In either case you should then have a new directory named 'git' that contains
26-
all the Git source code and history - it is basically a complete copy of what
27-
was on the server.
23+
The git:// protocol is faster and more efficient, but sometimes it is
24+
necessary to use http when behind corporate firewalls or what have you. In
25+
either case you should then have a new directory named 'git' that contains all
26+
the Git source code and history - it is basically a complete copy of what was
27+
on the server.
2828

29-
By default, Git will name the new directory it has checked
30-
out your cloned code into after whatever comes directly before the '.git' in
31-
the name of the cloned project. (ie. *git clone http://git.kernel.org/linux/kernel/git/torvalds/linux-2.6.git* will
32-
result in a new directory named 'linux-2.6')
29+
By default, Git will name the new directory it has checked out your cloned
30+
code into after whatever comes directly before the '.git' in the path of the
31+
cloned project. (ie. *git clone
32+
http://git.kernel.org/linux/kernel/git/torvalds/linux-2.6.git* will result in
33+
a new directory named 'linux-2.6')
3334

3435
### Initializing a New Repository ###
3536

36-
Assume you have a tarball project.tar.gz with your initial work. You
37-
can place it under git revision control as follows.
37+
Assume you have a tarball named project.tar.gz with your initial work. You can
38+
place it under git revision control as follows.
3839

3940
$ tar xzf project.tar.gz
4041
$ cd project

text/07_Normal_Workflow/0_ Normal_Workflow.markdown

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ newly modified content to the index. Finally, commit your changes with:
2828

2929
$ git commit
3030

31-
This will again prompt your for a message describing the change, and then
31+
This will again prompt you for a message describing the change, and then
3232
record a new version of the project.
3333

3434
Alternatively, instead of running `git add` beforehand, you can use
@@ -43,7 +43,7 @@ begin the commit message with a single short (less than 50 character)
4343
line summarizing the change, followed by a blank line and then a more
4444
thorough description. Tools that turn commits into email, for
4545
example, use the first line on the Subject: line and the rest of the
46-
commit in the body.
46+
commit message in the body.
4747

4848

4949
#### Git tracks content not files ####

text/08_Basic_Branching_and_Merging/0_ Basic_Branching_and_Merging.markdown

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ linkgit:git-merge[1]:
7979

8080
$ git merge branchname
8181

82-
merges the development in the branch "branchname" into the current
82+
merges the changes made in the branch "branchname" into the current
8383
branch. If there are conflicts--for example, if the same file is
8484
modified in two different ways in the remote branch and the local
8585
branch--then you are warned; the output may look something like this:
@@ -93,10 +93,10 @@ branch--then you are warned; the output may look something like this:
9393
Conflict markers are left in the problematic files, and after
9494
you resolve the conflicts manually, you can update the index
9595
with the contents and run git commit, as you normally would when
96-
creating a new file.
96+
modifying a file.
9797

9898
If you examine the resulting commit using gitk, you will see that it
99-
has two parents, one pointing to the top of the current branch, and
99+
has two parents: one pointing to the top of the current branch, and
100100
one to the top of the other branch.
101101

102102
### Resolving a merge ###
@@ -145,22 +145,20 @@ Or, if you've already committed the merge that you want to throw away,
145145

146146
$ git reset --hard ORIG_HEAD
147147

148-
However, this last command can be dangerous in some cases--never
149-
throw away a commit you have already committed if that commit may
150-
itself have been merged into another branch, as doing so may confuse
151-
further merges.
148+
However, this last command can be dangerous in some cases--never throw away a
149+
commit if that commit may itself have been merged into another branch, as
150+
doing so may confuse further merges.
152151

153152
### Fast-forward merges ###
154153

155-
There is one special case not mentioned above, which is treated
156-
differently. Normally, a merge results in a merge commit, with two
157-
parents, one pointing at each of the two lines of development that
158-
were merged.
154+
There is one special case not mentioned above, which is treated differently.
155+
Normally, a merge results in a merge commit with two parents, one for each of
156+
the two lines of development that were merged.
159157

160-
However, if the current branch is a descendant of the other--so every
161-
commit present in the one is already contained in the other--then git
162-
just performs a "fast forward"; the head of the current branch is moved
163-
forward to point at the head of the merged-in branch, without any new
164-
commits being created.
158+
However, if the current branch has not diverged from the other--so every
159+
commit present in the current branch is already contained in the other--then
160+
git just performs a "fast forward"; the head of the current branch is moved
161+
forward to point at the head of the merged-in branch, without any new commits
162+
being created.
165163

166164
[gitcast:c6-branch-merge]("GitCast #6: Branching and Merging")

0 commit comments

Comments
 (0)