Skip to content

Commit f61da79

Browse files
committed
got a good amount of the first section done or imported from the user guide
1 parent 633fd93 commit f61da79

23 files changed

+379
-16
lines changed

TODO.markdown

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
===Introduction
1212

13-
* Introduction (Why Git)
1413
* Git Object DB Basics (Git vs SVN, what is a DAG)
1514
* The Git Index
1615
* Git directory and working directory
@@ -55,7 +54,6 @@
5554
* Git Hooks
5655
* Git Recovery – corrupted blob objects
5756
* Advanced Merging – multiway, merge subtree
58-
* Git Submodules
5957

6058
===Working With Git
6159

layout/pdf_template.html

Lines changed: 40 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,49 @@
1111

1212
<div class="titlepage">
1313
<h1 class="no-toc">Git Community Book</h1>
14-
<h2 class="no-toc">What's New</h2>
15-
16-
<p class="no-toc">by Scott Chacon</p>
17-
<!-- also, the publisher's name would typically be printed here -->
14+
<h2 class="no-toc"></h2>
15+
<p class="no-toc">The open Git resource pulled together by the whole community</p>
1816
</div>
1917

2018
<div class="imprint">
21-
<p>Scott Chacon<br/>Website: www.jointheconversation.org</p>
19+
<h2>Authors</h2>
20+
Thank these guys:
21+
<p>
22+
Andy Parkins (andyparkins@gmail.com),
23+
Arjen Laarhoven (arjen@yaph.org),
24+
Brian Hetro (whee@smaertness.net),
25+
Carl Worth (cworth@cworth.org),
26+
Dan McGee (dpmcgee@gmail.com),
27+
David Kastrup (dak@gnu.org),
28+
Gerrit Pape (pape@smarden.org),
29+
Gustaf Hendeby (hendeby@isy.liu.se),
30+
J. Bruce Fields (bfields@fieldses.org),
31+
Jakub Narebski (jnareb@gmail.com),
32+
Jim Meyering (jim@meyering.net),
33+
Johan Herland (johan@herland.net),
34+
Johannes Schindelin (Johannes.Schindelin@gmx.de),
35+
Josh Triplett (josh@freedesktop.org),
36+
Junio C Hamano (gitster@pobox.com),
37+
Marcus Fritzsch (m@fritschy.de),
38+
Michael Coleman (tutufan@gmail.com),
39+
Michael Smith (msmith@cbnco.com),
40+
Mike Coleman (tutufan@gmail.com),
41+
Miklos Vajna (vmiklos@frugalware.org),
42+
Oliver Steele (steele@osteele.com),
43+
Pavel Roskin (proski@gnu.org),
44+
Ralf Wildenhues (Ralf.Wildenhues@gmx.de),
45+
Scott Chacon (schacon@gmail.com),
46+
Sergei Organov (osv@javad.com),
47+
Shawn Bohrer (shawn.bohrer@gmail.com),
48+
Steffen Prohaska (prohaska@zib.de),
49+
William Pursell (bill.pursell@gmail.com)
50+
</p>
51+
52+
<h2>Maintainer / Editor</h2>
53+
Bug this guy:
54+
<p>
55+
Scott Chacon (schacon@gmail.com)
56+
</p>
2257
</div>
2358

2459
<div class="chapter">

text/01_Introduction/0_ Introduction.markdown

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ and send me a patch or a pull-request.
4343

4444
### References ###
4545

46-
Much of this book is pulled together from different sources.
46+
Much of this book is pulled together from different sources and then added to.
47+
If you would like to read some of the original articles or resources, please
48+
visit them and thank the authors:
4749

4850
* [Git User Manual](http://www.kernel.org/pub/software/scm/git/docs/user-manual.html)
4951

5052
* ["My Git Workflow" blog post](http://osteele.com/archives/2008/05/my-git-workflow)
51-
(Oliver Steele <steele@osteele.com>)
53+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Some Terms ##
2+
3+
There are a number of terms used in Git that may be new to you. We're going
4+
to do a brief overview here to start to get you used to them before we really
5+
get into it.
6+
7+
* Repo
8+
* Blob
9+
* Tree
10+
* Commit
11+
* Tag
12+
* Object
13+
* Ref
14+
* Clone
15+
* Branch
16+
* Remote
17+
* Index
18+
* Working Directory
19+
* Git Directory
20+
21+
(!!TODO - fill in terms)
Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
##Git Object Db Basics
1+
## The Git Object Database ##
2+
3+
We already saw in <<understanding-commits>> that all commits are stored
4+
under a 40-digit "object name". In fact, all the information needed to
5+
represent the history of a project is stored in objects with such names.
6+
In each case the name is calculated by taking the SHA1 hash of the
7+
contents of the object. The SHA1 hash is a cryptographic hash function.
8+
What that means to us is that it is impossible to find two different
9+
objects with the same name. This has a number of advantages; among
10+
others:
11+
12+
- Git can quickly determine whether two objects are identical or not,
13+
just by comparing names.
14+
- Since object names are computed the same way in every repository, the
15+
same content stored in two repositories will always be stored under
16+
the same name.
17+
- Git can detect errors when it reads an object, by checking that the
18+
object's name is still the SHA1 hash of its contents.
19+
20+
(See <<object-details>> for the details of the object formatting and
21+
SHA1 calculation.)
22+
23+
There are four different types of objects: "blob", "tree", "commit", and
24+
"tag".
25+
26+
- A <<def_blob_object,"blob" object>> is used to store file data.
27+
- A <<def_tree_object,"tree" object>> ties one or more
28+
"blob" objects into a directory structure. In addition, a tree object
29+
can refer to other tree objects, thus creating a directory hierarchy.
30+
- A <<def_commit_object,"commit" object>> ties such directory hierarchies
31+
together into a <<def_DAG,directed acyclic graph>> of revisions--each
32+
commit contains the object name of exactly one tree designating the
33+
directory hierarchy at the time of the commit. In addition, a commit
34+
refers to "parent" commit objects that describe the history of how we
35+
arrived at that directory hierarchy.
36+
- A <<def_tag_object,"tag" object>> symbolically identifies and can be
37+
used to sign other objects. It contains the object name and type of
38+
another object, a symbolic name (of course!) and, optionally, a
39+
signature.
40+
41+
The object types in some more detail:
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
### Tree Object ###
2+
3+
The ever-versatile linkgit:git-show[1] command can also be used to
4+
examine tree objects, but linkgit:git-ls-tree[1] will give you more
5+
details:
6+
7+
$ git ls-tree fb3a8bdd0ce
8+
100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c .gitignore
9+
100644 blob 5529b198e8d14decbe4ad99db3f7fb632de0439d .mailmap
10+
100644 blob 6ff87c4664981e4397625791c8ea3bbb5f2279a3 COPYING
11+
040000 tree 2fb783e477100ce076f6bf57e4a6f026013dc745 Documentation
12+
100755 blob 3c0032cec592a765692234f1cba47dfdcc3a9200 GIT-VERSION-GEN
13+
100644 blob 289b046a443c0647624607d471289b2c7dcd470b INSTALL
14+
100644 blob 4eb463797adc693dc168b926b6932ff53f17d0b1 Makefile
15+
100644 blob 548142c327a6790ff8821d67c2ee1eff7a656b52 README
16+
...
17+
18+
As you can see, a tree object contains a list of entries, each with a
19+
mode, object type, SHA1 name, and name, sorted by name. It represents
20+
the contents of a single directory tree.
21+
22+
The object type may be a blob, representing the contents of a file, or
23+
another tree, representing the contents of a subdirectory. Since trees
24+
and blobs, like all other objects, are named by the SHA1 hash of their
25+
contents, two trees have the same SHA1 name if and only if their
26+
contents (including, recursively, the contents of all subdirectories)
27+
are identical. This allows git to quickly determine the differences
28+
between two related tree objects, since it can ignore any entries with
29+
identical object names.
30+
31+
(Note: in the presence of submodules, trees may also have commits as
32+
entries. See <<submodules>> for documentation.)
33+
34+
Note that the files all have mode 644 or 755: git actually only pays
35+
attention to the executable bit.
36+
37+
### Blob Object ###
38+
39+
You can use linkgit:git-show[1] to examine the contents of a blob; take,
40+
for example, the blob in the entry for "COPYING" from the tree above:
41+
42+
$ git show 6ff87c4664
43+
44+
Note that the only valid version of the GPL as far as this project
45+
is concerned is _this_ particular version of the license (ie v2, not
46+
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
47+
...
48+
49+
A "blob" object is nothing but a binary blob of data. It doesn't refer
50+
to anything else or have attributes of any kind.
51+
52+
Since the blob is entirely defined by its data, if two files in a
53+
directory tree (or in multiple different versions of the repository)
54+
have the same contents, they will share the same blob object. The object
55+
is totally independent of its location in the directory tree, and
56+
renaming a file does not change the object that file is associated with.
57+
58+
Note that any tree or blob object can be examined using
59+
linkgit:git-show[1] with the <revision>:<path> syntax. This can
60+
sometimes be useful for browsing the contents of a tree that is not
61+
currently checked out.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
### Commit Object ###
2+
3+
The "commit" object links a physical state of a tree with a description
4+
of how we got there and why. Use the --pretty=raw option to
5+
linkgit:git-show[1] or linkgit:git-log[1] to examine your favorite
6+
commit:
7+
8+
$ git show -s --pretty=raw 2be7fcb476
9+
commit 2be7fcb4764f2dbcee52635b91fedb1b3dcf7ab4
10+
tree fb3a8bdd0ceddd019615af4d57a53f43d8cee2bf
11+
parent 257a84d9d02e90447b149af58b271c19405edb6a
12+
author Dave Watson <dwatson@mimvista.com> 1187576872 -0400
13+
committer Junio C Hamano <gitster@pobox.com> 1187591163 -0700
14+
15+
Fix misspelling of 'suppress' in docs
16+
17+
Signed-off-by: Junio C Hamano <gitster@pobox.com>
18+
19+
As you can see, a commit is defined by:
20+
21+
- a tree: The SHA1 name of a tree object (as defined below), representing
22+
the contents of a directory at a certain point in time.
23+
- parent(s): The SHA1 name of some number of commits which represent the
24+
immediately previous step(s) in the history of the project. The
25+
example above has one parent; merge commits may have more than
26+
one. A commit with no parents is called a "root" commit, and
27+
represents the initial revision of a project. Each project must have
28+
at least one root. A project can also have multiple roots, though
29+
that isn't common (or necessarily a good idea).
30+
- an author: The name of the person responsible for this change, together
31+
with its date.
32+
- a committer: The name of the person who actually created the commit,
33+
with the date it was done. This may be different from the author, for
34+
example, if the author was someone who wrote a patch and emailed it
35+
to the person who used it to create the commit.
36+
- a comment describing this commit.
37+
38+
Note that a commit does not itself contain any information about what
39+
actually changed; all changes are calculated by comparing the contents
40+
of the tree referred to by this commit with the trees associated with
41+
its parents. In particular, git does not attempt to record file renames
42+
explicitly, though it can identify cases where the existence of the same
43+
file data at changing paths suggests a rename. (See, for example, the
44+
-M option to linkgit:git-diff[1]).
45+
46+
A commit is usually created by linkgit:git-commit[1], which creates a
47+
commit whose parent is normally the current HEAD, and whose tree is
48+
taken from the content currently stored in the index.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
### Trust ###
2+
3+
If you receive the SHA1 name of a blob from one source, and its contents
4+
from another (possibly untrusted) source, you can still trust that those
5+
contents are correct as long as the SHA1 name agrees. This is because
6+
the SHA1 is designed so that it is infeasible to find different contents
7+
that produce the same hash.
8+
9+
Similarly, you need only trust the SHA1 name of a top-level tree object
10+
to trust the contents of the entire directory that it refers to, and if
11+
you receive the SHA1 name of a commit from a trusted source, then you
12+
can easily verify the entire history of commits reachable through
13+
parents of that commit, and all of those contents of the trees referred
14+
to by those commits.
15+
16+
So to introduce some real trust in the system, the only thing you need
17+
to do is to digitally sign just 'one' special note, which includes the
18+
name of a top-level commit. Your digital signature shows others
19+
that you trust that commit, and the immutability of the history of
20+
commits tells others that they can trust the whole history.
21+
22+
In other words, you can easily validate a whole archive by just
23+
sending out a single email that tells the people the name (SHA1 hash)
24+
of the top commit, and digitally sign that email using something
25+
like GPG/PGP.
26+
27+
To assist in this, git also provides the tag object...
28+
29+
### Tag Object ###
30+
31+
A tag object contains an object, object type, tag name, the name of the
32+
person ("tagger") who created the tag, and a message, which may contain
33+
a signature, as can be seen using linkgit:git-cat-file[1]:
34+
35+
$ git cat-file tag v1.5.0
36+
object 437b1b20df4b356c9342dac8d38849f24ef44f27
37+
type commit
38+
tag v1.5.0
39+
tagger Junio C Hamano <junkio@cox.net> 1171411200 +0000
40+
41+
GIT 1.5.0
42+
-----BEGIN PGP SIGNATURE-----
43+
Version: GnuPG v1.4.6 (GNU/Linux)
44+
45+
iD8DBQBF0lGqwMbZpPMRm5oRAuRiAJ9ohBLd7s2kqjkKlq1qqC57SbnmzQCdG4ui
46+
nLE/L9aUXdWeTFPron96DLA=
47+
=2E+0
48+
-----END PGP SIGNATURE-----
49+
50+
See the linkgit:git-tag[1] command to learn how to create and verify tag
51+
objects. (Note that linkgit:git-tag[1] can also be used to create
52+
"lightweight tags", which are not tag objects at all, but just simple
53+
references whose names begin with "refs/tags/").
Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
##The Git Index
1+
## The Git Index ##
2+
3+
The index is a binary file (generally kept in .git/index) containing a
4+
sorted list of path names, each with permissions and the SHA1 of a blob
5+
object; linkgit:git-ls-files[1] can show you the contents of the index:
6+
7+
$ git ls-files --stage
8+
100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0 .gitignore
9+
100644 5529b198e8d14decbe4ad99db3f7fb632de0439d 0 .mailmap
10+
100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0 COPYING
11+
100644 a37b2152bd26be2c2289e1f57a292534a51a93c7 0 Documentation/.gitignore
12+
100644 fbefe9a45b00a54b58d94d06eca48b03d40a50e0 0 Documentation/Makefile
13+
...
14+
100644 2511aef8d89ab52be5ec6a5e46236b4b6bcd07ea 0 xdiff/xtypes.h
15+
100644 2ade97b2574a9f77e7ae4002a4e07a6a38e46d07 0 xdiff/xutils.c
16+
100644 d5de8292e05e7c36c4b68857c1cf9855e3d2f70a 0 xdiff/xutils.h
17+
18+
Note that in older documentation you may see the index called the
19+
"current directory cache" or just the "cache". It has three important
20+
properties:
21+
22+
1. The index contains all the information necessary to generate a single
23+
(uniquely determined) tree object.
24+
25+
For example, running linkgit:git-commit[1] generates this tree object
26+
from the index, stores it in the object database, and uses it as the
27+
tree object associated with the new commit.
28+
29+
2. The index enables fast comparisons between the tree object it defines
30+
and the working tree.
31+
32+
It does this by storing some additional data for each entry (such as
33+
the last modified time). This data is not displayed above, and is not
34+
stored in the created tree object, but it can be used to determine
35+
quickly which files in the working directory differ from what was
36+
stored in the index, and thus save git from having to read all of the
37+
data from such files to look for changes.
38+
39+
3. It can efficiently represent information about merge conflicts
40+
between different tree objects, allowing each pathname to be
41+
associated with sufficient information about the trees involved that
42+
you can create a three-way merge between them.
43+
44+
We saw in <<conflict-resolution>> that during a merge the index can
45+
store multiple versions of a single file (called "stages"). The third
46+
column in the linkgit:git-ls-files[1] output above is the stage
47+
number, and will take on values other than 0 for files with merge
48+
conflicts.
49+
50+
The index is thus a sort of temporary staging area, which is filled with
51+
a tree which you are in the process of working on.
52+
53+
If you blow the index away entirely, you generally haven't lost any
54+
information as long as you have the name of the tree that it described.
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
##Git Directory and Working Directory
1+
## Git Directory and Working Directory ##
2+
3+
(explain the git directory)
4+
5+
(explain the working directory)

0 commit comments

Comments
 (0)