Update git documentation
[TortoiseGit.git] / doc / source / en / TortoiseGit / git_doc / user-manual.xml
blob9d0d235af41f1ce6de9e3c8cf068cabbea4fc31c
1 <?xml version="1.0" encoding="UTF-8"?>\r
2 <!DOCTYPE sect2 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">\r
3 \r
4 <sect2 lang="en" id="git_user-manual">\r
5     <title>Git User Manual</title>\r
6 <simpara>Git is a fast distributed revision control system.</simpara>\r
7 <simpara>This manual is designed to be readable by someone with basic UNIX\r
8 command-line skills, but no previous knowledge of Git.</simpara>\r
9 <simpara><xref linkend="Git User Manual_repositories-and-branches"/> and <xref linkend="Git User Manual_exploring-git-history"/> explain how\r
10 to fetch and study a project using git--read these chapters to learn how\r
11 to build and test a particular version of a software project, search for\r
12 regressions, and so on.</simpara>\r
13 <simpara>People needing to do actual development will also want to read\r
14 <xref linkend="Git User Manual_Developing-With-git"/> and <xref linkend="Git User Manual_sharing-development"/>.</simpara>\r
15 <simpara>Further chapters cover more specialized topics.</simpara>\r
16 <simpara>Comprehensive reference documentation is available through the man\r
17 pages, or <xref linkend="git-help(1)" /> command.  For example, for the command\r
18 <emphasis>git clone &lt;repo&gt;</emphasis>, you can either use:</simpara>\r
19 <literallayout>$ man git-clone</literallayout>\r
20 <simpara>or:</simpara>\r
21 <literallayout>$ git help clone</literallayout>\r
22 <simpara>With the latter, you can use the manual viewer of your choice; see\r
23 <xref linkend="git-help(1)" /> for more information.</simpara>\r
24 <simpara>See also <xref linkend="Git User Manual_git-quick-start"/> for a brief overview of Git commands,\r
25 without any explanation.</simpara>\r
26 <simpara>Finally, see <xref linkend="Git User Manual_todo"/> for ways that you can help make this manual more\r
27 complete.</simpara>\r
28 <section id="Git User Manual_repositories-and-branches">\r
29 <title>Repositories and Branches</title>\r
30 <section id="Git User Manual_how-to-get-a-git-repository">\r
31 <title>How to get a Git repository</title>\r
32 <simpara>It will be useful to have a Git repository to experiment with as you\r
33 read this manual.</simpara>\r
34 <simpara>The best way to get one is by using the <xref linkend="git-clone(1)" /> command to\r
35 download a copy of an existing repository.  If you don't already have a\r
36 project in mind, here are some interesting examples:</simpara>\r
37 <literallayout>        # Git itself (approx. 40MB download):\r
38 $ git clone git://git.kernel.org/pub/scm/git/git.git\r
39         # the Linux kernel (approx. 640MB download):\r
40 $ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git</literallayout>\r
41 <simpara>The initial clone may be time-consuming for a large project, but you\r
42 will only need to clone once.</simpara>\r
43 <simpara>The clone command creates a new directory named after the project\r
44 (<emphasis>git</emphasis> or <emphasis>linux</emphasis> in the examples above).  After you cd into this\r
45 directory, you will see that it contains a copy of the project files,\r
46 called the <link linkend="Git User Manual_def_working_tree">working tree</link>, together with a special\r
47 top-level directory named <emphasis>.git</emphasis>, which contains all the information\r
48 about the history of the project.</simpara>\r
49 </section>\r
50 <section id="Git User Manual_how-to-check-out">\r
51 <title>How to check out a different version of a project</title>\r
52 <simpara>Git is best thought of as a tool for storing the history of a collection\r
53 of files.  It stores the history as a compressed collection of\r
54 interrelated snapshots of the project's contents.  In Git each such\r
55 version is called a <link linkend="Git User Manual_def_commit">commit</link>.</simpara>\r
56 <simpara>Those snapshots aren't necessarily all arranged in a single line from\r
57 oldest to newest; instead, work may simultaneously proceed along\r
58 parallel lines of development, called <link linkend="Git User Manual_def_branch">branches</link>, which may\r
59 merge and diverge.</simpara>\r
60 <simpara>A single Git repository can track development on multiple branches.  It\r
61 does this by keeping a list of <link linkend="Git User Manual_def_head">heads</link> which reference the\r
62 latest commit on each branch; the <xref linkend="git-branch(1)" /> command shows\r
63 you the list of branch heads:</simpara>\r
64 <literallayout>$ git branch\r
65 * master</literallayout>\r
66 <simpara>A freshly cloned repository contains a single branch head, by default\r
67 named "master", with the working directory initialized to the state of\r
68 the project referred to by that branch head.</simpara>\r
69 <simpara>Most projects also use <link linkend="Git User Manual_def_tag">tags</link>.  Tags, like heads, are\r
70 references into the project's history, and can be listed using the\r
71 <xref linkend="git-tag(1)" /> command:</simpara>\r
72 <literallayout>$ git tag -l\r
73 v2.6.11\r
74 v2.6.11-tree\r
75 v2.6.12\r
76 v2.6.12-rc2\r
77 v2.6.12-rc3\r
78 v2.6.12-rc4\r
79 v2.6.12-rc5\r
80 v2.6.12-rc6\r
81 v2.6.13\r
82 ...</literallayout>\r
83 <simpara>Tags are expected to always point at the same version of a project,\r
84 while heads are expected to advance as development progresses.</simpara>\r
85 <simpara>Create a new branch head pointing to one of these versions and check it\r
86 out using <xref linkend="git-checkout(1)" />:</simpara>\r
87 <literallayout>$ git checkout -b new v2.6.13</literallayout>\r
88 <simpara>The working directory then reflects the contents that the project had\r
89 when it was tagged v2.6.13, and <xref linkend="git-branch(1)" /> shows two\r
90 branches, with an asterisk marking the currently checked-out branch:</simpara>\r
91 <literallayout>$ git branch\r
92   master\r
93 * new</literallayout>\r
94 <simpara>If you decide that you'd rather see version 2.6.17, you can modify\r
95 the current branch to point at v2.6.17 instead, with</simpara>\r
96 <literallayout>$ git reset --hard v2.6.17</literallayout>\r
97 <simpara>Note that if the current branch head was your only reference to a\r
98 particular point in history, then resetting that branch may leave you\r
99 with no way to find the history it used to point to; so use this command\r
100 carefully.</simpara>\r
101 </section>\r
102 <section id="Git User Manual_understanding-commits">\r
103 <title>Understanding History: Commits</title>\r
104 <simpara>Every change in the history of a project is represented by a commit.\r
105 The <xref linkend="git-show(1)" /> command shows the most recent commit on the\r
106 current branch:</simpara>\r
107 <literallayout>$ git show\r
108 commit 17cf781661e6d38f737f15f53ab552f1e95960d7\r
109 Author: Linus Torvalds &lt;torvalds@ppc970.osdl.org.(none)&gt;\r
110 Date:   Tue Apr 19 14:11:06 2005 -0700\r
112     Remove duplicate getenv(DB_ENVIRONMENT) call\r
114     Noted by Tony Luck.\r
116 diff --git a/init-db.c b/init-db.c\r
117 index 65898fa..b002dc6 100644\r
118 --- a/init-db.c\r
119 +++ b/init-db.c\r
120 @@ -7,7 +7,7 @@\r
122  int main(int argc, char **argv)\r
123  {\r
124 -       char *sha1_dir = getenv(DB_ENVIRONMENT), *path;\r
125 +       char *sha1_dir, *path;\r
126         int len, i;\r
128         if (mkdir(".git", 0755) &lt; 0) {</literallayout>\r
129 <simpara>As you can see, a commit shows who made the latest change, what they\r
130 did, and why.</simpara>\r
131 <simpara>Every commit has a 40-hexdigit id, sometimes called the "object name" or the\r
132 "SHA-1 id", shown on the first line of the <emphasis>git show</emphasis> output.  You can usually\r
133 refer to a commit by a shorter name, such as a tag or a branch name, but this\r
134 longer name can also be useful.  Most importantly, it is a globally unique\r
135 name for this commit: so if you tell somebody else the object name (for\r
136 example in email), then you are guaranteed that name will refer to the same\r
137 commit in their repository that it does in yours (assuming their repository\r
138 has that commit at all).  Since the object name is computed as a hash over the\r
139 contents of the commit, you are guaranteed that the commit can never change\r
140 without its name also changing.</simpara>\r
141 <simpara>In fact, in <xref linkend="Git User Manual_git-concepts"/> we shall see that everything stored in Git\r
142 history, including file data and directory contents, is stored in an object\r
143 with a name that is a hash of its contents.</simpara>\r
144 <section id="Git User Manual_understanding-reachability">\r
145 <title>Understanding history: commits, parents, and reachability</title>\r
146 <simpara>Every commit (except the very first commit in a project) also has a\r
147 parent commit which shows what happened before this commit.\r
148 Following the chain of parents will eventually take you back to the\r
149 beginning of the project.</simpara>\r
150 <simpara>However, the commits do not form a simple list; Git allows lines of\r
151 development to diverge and then reconverge, and the point where two\r
152 lines of development reconverge is called a "merge".  The commit\r
153 representing a merge can therefore have more than one parent, with\r
154 each parent representing the most recent commit on one of the lines\r
155 of development leading to that point.</simpara>\r
156 <simpara>The best way to see how this works is using the <xref linkend="gitk(1)" />\r
157 command; running gitk now on a Git repository and looking for merge\r
158 commits will help understand how Git organizes history.</simpara>\r
159 <simpara>In the following, we say that commit X is "reachable" from commit Y\r
160 if commit X is an ancestor of commit Y.  Equivalently, you could say\r
161 that Y is a descendant of X, or that there is a chain of parents\r
162 leading from commit Y to commit X.</simpara>\r
163 </section>\r
164 <section id="Git User Manual_history-diagrams">\r
165 <title>Understanding history: History diagrams</title>\r
166 <simpara>We will sometimes represent Git history using diagrams like the one\r
167 below.  Commits are shown as "o", and the links between them with\r
168 lines drawn with - / and \.  Time goes left to right:</simpara>\r
169 <literallayout class="monospaced">         o--o--o &lt;-- Branch A\r
170         /\r
171  o--o--o &lt;-- master\r
172         \\r
173          o--o--o &lt;-- Branch B</literallayout>\r
174 <simpara>If we need to talk about a particular commit, the character "o" may\r
175 be replaced with another letter or number.</simpara>\r
176 </section>\r
177 <section id="Git User Manual_what-is-a-branch">\r
178 <title>Understanding history: What is a branch?</title>\r
179 <simpara>When we need to be precise, we will use the word "branch" to mean a line\r
180 of development, and "branch head" (or just "head") to mean a reference\r
181 to the most recent commit on a branch.  In the example above, the branch\r
182 head named "A" is a pointer to one particular commit, but we refer to\r
183 the line of three commits leading up to that point as all being part of\r
184 "branch A".</simpara>\r
185 <simpara>However, when no confusion will result, we often just use the term\r
186 "branch" both for branches and for branch heads.</simpara>\r
187 </section>\r
188 </section>\r
189 <section id="Git User Manual_manipulating-branches">\r
190 <title>Manipulating branches</title>\r
191 <simpara>Creating, deleting, and modifying branches is quick and easy; here's\r
192 a summary of the commands:</simpara>\r
193 <variablelist>\r
194 <varlistentry>\r
195 <term>\r
196 <emphasis>git branch</emphasis>\r
197 </term>\r
198 <listitem>\r
199 <simpara>\r
200         list all branches.\r
201 </simpara>\r
202 </listitem>\r
203 </varlistentry>\r
204 <varlistentry>\r
205 <term>\r
206 <emphasis>git branch &lt;branch&gt;</emphasis>\r
207 </term>\r
208 <listitem>\r
209 <simpara>\r
210         create a new branch named <emphasis>&lt;branch&gt;</emphasis>, referencing the same\r
211         point in history as the current branch.\r
212 </simpara>\r
213 </listitem>\r
214 </varlistentry>\r
215 <varlistentry>\r
216 <term>\r
217 <emphasis>git branch &lt;branch&gt; &lt;start-point&gt;</emphasis>\r
218 </term>\r
219 <listitem>\r
220 <simpara>\r
221         create a new branch named <emphasis>&lt;branch&gt;</emphasis>, referencing\r
222         <emphasis>&lt;start-point&gt;</emphasis>, which may be specified any way you like,\r
223         including using a branch name or a tag name.\r
224 </simpara>\r
225 </listitem>\r
226 </varlistentry>\r
227 <varlistentry>\r
228 <term>\r
229 <emphasis>git branch -d &lt;branch&gt;</emphasis>\r
230 </term>\r
231 <listitem>\r
232 <simpara>\r
233         delete the branch <emphasis>&lt;branch&gt;</emphasis>; if the branch is not fully\r
234         merged in its upstream branch or contained in the current branch,\r
235         this command will fail with a warning.\r
236 </simpara>\r
237 </listitem>\r
238 </varlistentry>\r
239 <varlistentry>\r
240 <term>\r
241 <emphasis>git branch -D &lt;branch&gt;</emphasis>\r
242 </term>\r
243 <listitem>\r
244 <simpara>\r
245         delete the branch <emphasis>&lt;branch&gt;</emphasis> irrespective of its merged status.\r
246 </simpara>\r
247 </listitem>\r
248 </varlistentry>\r
249 <varlistentry>\r
250 <term>\r
251 <emphasis>git checkout &lt;branch&gt;</emphasis>\r
252 </term>\r
253 <listitem>\r
254 <simpara>\r
255         make the current branch <emphasis>&lt;branch&gt;</emphasis>, updating the working\r
256         directory to reflect the version referenced by <emphasis>&lt;branch&gt;</emphasis>.\r
257 </simpara>\r
258 </listitem>\r
259 </varlistentry>\r
260 <varlistentry>\r
261 <term>\r
262 <emphasis>git checkout -b &lt;new&gt; &lt;start-point&gt;</emphasis>\r
263 </term>\r
264 <listitem>\r
265 <simpara>\r
266         create a new branch <emphasis>&lt;new&gt;</emphasis> referencing <emphasis>&lt;start-point&gt;</emphasis>, and\r
267         check it out.\r
268 </simpara>\r
269 </listitem>\r
270 </varlistentry>\r
271 </variablelist>\r
272 <simpara>The special symbol "HEAD" can always be used to refer to the current\r
273 branch.  In fact, Git uses a file named <emphasis>HEAD</emphasis> in the <emphasis>.git</emphasis> directory\r
274 to remember which branch is current:</simpara>\r
275 <literallayout>$ cat .git/HEAD\r
276 ref: refs/heads/master</literallayout>\r
277 </section>\r
278 <section id="Git User Manual_detached-head">\r
279 <title>Examining an old version without creating a new branch</title>\r
280 <simpara>The <emphasis>git checkout</emphasis> command normally expects a branch head, but will also\r
281 accept an arbitrary commit; for example, you can check out the commit\r
282 referenced by a tag:</simpara>\r
283 <literallayout>$ git checkout v2.6.17\r
284 Note: checking out 'v2.6.17'.\r
286 You are in 'detached HEAD' state. You can look around, make experimental\r
287 changes and commit them, and you can discard any commits you make in this\r
288 state without impacting any branches by performing another checkout.\r
290 If you want to create a new branch to retain commits you create, you may\r
291 do so (now or later) by using -b with the checkout command again. Example:\r
293   git checkout -b new_branch_name\r
295 HEAD is now at 427abfa... Linux v2.6.17</literallayout>\r
296 <simpara>The HEAD then refers to the SHA-1 of the commit instead of to a branch,\r
297 and git branch shows that you are no longer on a branch:</simpara>\r
298 <literallayout>$ cat .git/HEAD\r
299 427abfa28afedffadfca9dd8b067eb6d36bac53f\r
300 $ git branch\r
301 * (detached from v2.6.17)\r
302   master</literallayout>\r
303 <simpara>In this case we say that the HEAD is "detached".</simpara>\r
304 <simpara>This is an easy way to check out a particular version without having to\r
305 make up a name for the new branch.   You can still create a new branch\r
306 (or tag) for this version later if you decide to.</simpara>\r
307 </section>\r
308 <section id="Git User Manual_examining-remote-branches">\r
309 <title>Examining branches from a remote repository</title>\r
310 <simpara>The "master" branch that was created at the time you cloned is a copy\r
311 of the HEAD in the repository that you cloned from.  That repository\r
312 may also have had other branches, though, and your local repository\r
313 keeps branches which track each of those remote branches, called\r
314 remote-tracking branches, which you\r
315 can view using the <emphasis>-r</emphasis> option to <xref linkend="git-branch(1)" />:</simpara>\r
316 <literallayout>$ git branch -r\r
317   origin/HEAD\r
318   origin/html\r
319   origin/maint\r
320   origin/man\r
321   origin/master\r
322   origin/next\r
323   origin/pu\r
324   origin/todo</literallayout>\r
325 <simpara>In this example, "origin" is called a remote repository, or "remote"\r
326 for short. The branches of this repository are called "remote\r
327 branches" from our point of view. The remote-tracking branches listed\r
328 above were created based on the remote branches at clone time and will\r
329 be updated by <emphasis>git fetch</emphasis> (hence <emphasis>git pull</emphasis>) and <emphasis>git push</emphasis>. See\r
330 <xref linkend="Git User Manual_Updating-a-repository-With-git-fetch"/> for details.</simpara>\r
331 <simpara>You might want to build on one of these remote-tracking branches\r
332 on a branch of your own, just as you would for a tag:</simpara>\r
333 <literallayout>$ git checkout -b my-todo-copy origin/todo</literallayout>\r
334 <simpara>You can also check out <emphasis>origin/todo</emphasis> directly to examine it or\r
335 write a one-off patch.  See <link linkend="Git User Manual_detached-head">detached head</link>.</simpara>\r
336 <simpara>Note that the name "origin" is just the name that Git uses by default\r
337 to refer to the repository that you cloned from.</simpara>\r
338 </section>\r
339 <section id="Git User Manual_how-git-stores-references">\r
340 <title>Naming branches, tags, and other references</title>\r
341 <simpara>Branches, remote-tracking branches, and tags are all references to\r
342 commits.  All references are named with a slash-separated path name\r
343 starting with <emphasis>refs</emphasis>; the names we've been using so far are actually\r
344 shorthand:</simpara>\r
345 <itemizedlist>\r
346 <listitem>\r
347 <simpara>\r
348 The branch <emphasis>test</emphasis> is short for <emphasis>refs/heads/test</emphasis>.\r
349 </simpara>\r
350 </listitem>\r
351 <listitem>\r
352 <simpara>\r
353 The tag <emphasis>v2.6.18</emphasis> is short for <emphasis>refs/tags/v2.6.18</emphasis>.\r
354 </simpara>\r
355 </listitem>\r
356 <listitem>\r
357 <simpara>\r
358 <emphasis>origin/master</emphasis> is short for <emphasis>refs/remotes/origin/master</emphasis>.\r
359 </simpara>\r
360 </listitem>\r
361 </itemizedlist>\r
362 <simpara>The full name is occasionally useful if, for example, there ever\r
363 exists a tag and a branch with the same name.</simpara>\r
364 <simpara>(Newly created refs are actually stored in the <emphasis>.git/refs</emphasis> directory,\r
365 under the path given by their name.  However, for efficiency reasons\r
366 they may also be packed together in a single file; see\r
367 <xref linkend="git-pack-refs(1)" />).</simpara>\r
368 <simpara>As another useful shortcut, the "HEAD" of a repository can be referred\r
369 to just using the name of that repository.  So, for example, "origin"\r
370 is usually a shortcut for the HEAD branch in the repository "origin".</simpara>\r
371 <simpara>For the complete list of paths which Git checks for references, and\r
372 the order it uses to decide which to choose when there are multiple\r
373 references with the same shorthand name, see the "SPECIFYING\r
374 REVISIONS" section of <xref linkend="gitrevisions(7)" />.</simpara>\r
375 </section>\r
376 <section id="Git User Manual_Updating-a-repository-With-git-fetch">\r
377 <title>Updating a repository with git fetch</title>\r
378 <simpara>After you clone a repository and commit a few changes of your own, you\r
379 may wish to check the original repository for updates.</simpara>\r
380 <simpara>The <emphasis>git-fetch</emphasis> command, with no arguments, will update all of the\r
381 remote-tracking branches to the latest version found in the original\r
382 repository.  It will not touch any of your own branches--not even the\r
383 "master" branch that was created for you on clone.</simpara>\r
384 </section>\r
385 <section id="Git User Manual_fetching-branches">\r
386 <title>Fetching branches from other repositories</title>\r
387 <simpara>You can also track branches from repositories other than the one you\r
388 cloned from, using <xref linkend="git-remote(1)" />:</simpara>\r
389 <literallayout>$ git remote add staging git://git.kernel.org/.../gregkh/staging.git\r
390 $ git fetch staging\r
391 ...\r
392 From git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging\r
393  * [new branch]      master     -&gt; staging/master\r
394  * [new branch]      staging-linus -&gt; staging/staging-linus\r
395  * [new branch]      staging-next -&gt; staging/staging-next</literallayout>\r
396 <simpara>New remote-tracking branches will be stored under the shorthand name\r
397 that you gave <emphasis>git remote add</emphasis>, in this case <emphasis>staging</emphasis>:</simpara>\r
398 <literallayout>$ git branch -r\r
399   origin/HEAD -&gt; origin/master\r
400   origin/master\r
401   staging/master\r
402   staging/staging-linus\r
403   staging/staging-next</literallayout>\r
404 <simpara>If you run <emphasis>git fetch &lt;remote&gt;</emphasis> later, the remote-tracking branches\r
405 for the named <emphasis>&lt;remote&gt;</emphasis> will be updated.</simpara>\r
406 <simpara>If you examine the file <emphasis>.git/config</emphasis>, you will see that Git has added\r
407 a new stanza:</simpara>\r
408 <literallayout>$ cat .git/config\r
409 ...\r
410 [remote "staging"]\r
411         url = git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git\r
412         fetch = +refs/heads/*:refs/remotes/staging/*\r
413 ...</literallayout>\r
414 <simpara>This is what causes Git to track the remote's branches; you may modify\r
415 or delete these configuration options by editing <emphasis>.git/config</emphasis> with a\r
416 text editor.  (See the "CONFIGURATION FILE" section of\r
417 <xref linkend="git-config(1)" /> for details.)</simpara>\r
418 </section>\r
419 </section>\r
420 <section id="Git User Manual_exploring-git-history">\r
421 <title>Exploring Git history</title>\r
422 <simpara>Git is best thought of as a tool for storing the history of a\r
423 collection of files.  It does this by storing compressed snapshots of\r
424 the contents of a file hierarchy, together with "commits" which show\r
425 the relationships between these snapshots.</simpara>\r
426 <simpara>Git provides extremely flexible and fast tools for exploring the\r
427 history of a project.</simpara>\r
428 <simpara>We start with one specialized tool that is useful for finding the\r
429 commit that introduced a bug into a project.</simpara>\r
430 <section id="Git User Manual_using-bisect">\r
431 <title>How to use bisect to find a regression</title>\r
432 <simpara>Suppose version 2.6.18 of your project worked, but the version at\r
433 "master" crashes.  Sometimes the best way to find the cause of such a\r
434 regression is to perform a brute-force search through the project's\r
435 history to find the particular commit that caused the problem.  The\r
436 <xref linkend="git-bisect(1)" /> command can help you do this:</simpara>\r
437 <literallayout>$ git bisect start\r
438 $ git bisect good v2.6.18\r
439 $ git bisect bad master\r
440 Bisecting: 3537 revisions left to test after this\r
441 [65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6]</literallayout>\r
442 <simpara>If you run <emphasis>git branch</emphasis> at this point, you'll see that Git has\r
443 temporarily moved you in "(no branch)". HEAD is now detached from any\r
444 branch and points directly to a commit (with commit id 65934&#8230;) that\r
445 is reachable from "master" but not from v2.6.18. Compile and test it,\r
446 and see whether it crashes. Assume it does crash. Then:</simpara>\r
447 <literallayout>$ git bisect bad\r
448 Bisecting: 1769 revisions left to test after this\r
449 [7eff82c8b1511017ae605f0c99ac275a7e21b867] i2c-core: Drop useless bitmaskings</literallayout>\r
450 <simpara>checks out an older version.  Continue like this, telling Git at each\r
451 stage whether the version it gives you is good or bad, and notice\r
452 that the number of revisions left to test is cut approximately in\r
453 half each time.</simpara>\r
454 <simpara>After about 13 tests (in this case), it will output the commit id of\r
455 the guilty commit.  You can then examine the commit with\r
456 <xref linkend="git-show(1)" />, find out who wrote it, and mail them your bug\r
457 report with the commit id.  Finally, run</simpara>\r
458 <literallayout>$ git bisect reset</literallayout>\r
459 <simpara>to return you to the branch you were on before.</simpara>\r
460 <simpara>Note that the version which <emphasis>git bisect</emphasis> checks out for you at each\r
461 point is just a suggestion, and you're free to try a different\r
462 version if you think it would be a good idea.  For example,\r
463 occasionally you may land on a commit that broke something unrelated;\r
464 run</simpara>\r
465 <literallayout>$ git bisect visualize</literallayout>\r
466 <simpara>which will run gitk and label the commit it chose with a marker that\r
467 says "bisect".  Choose a safe-looking commit nearby, note its commit\r
468 id, and check it out with:</simpara>\r
469 <literallayout>$ git reset --hard fb47ddb2db...</literallayout>\r
470 <simpara>then test, run <emphasis>bisect good</emphasis> or <emphasis>bisect bad</emphasis> as appropriate, and\r
471 continue.</simpara>\r
472 <simpara>Instead of <emphasis>git bisect visualize</emphasis> and then <emphasis>git reset --hard\r
473 fb47ddb2db...</emphasis>, you might just want to tell Git that you want to skip\r
474 the current commit:</simpara>\r
475 <literallayout>$ git bisect skip</literallayout>\r
476 <simpara>In this case, though, Git may not eventually be able to tell the first\r
477 bad one between some first skipped commits and a later bad commit.</simpara>\r
478 <simpara>There are also ways to automate the bisecting process if you have a\r
479 test script that can tell a good from a bad commit. See\r
480 <xref linkend="git-bisect(1)" /> for more information about this and other <emphasis>git\r
481 bisect</emphasis> features.</simpara>\r
482 </section>\r
483 <section id="Git User Manual_naming-commits">\r
484 <title>Naming commits</title>\r
485 <simpara>We have seen several ways of naming commits already:</simpara>\r
486 <itemizedlist>\r
487 <listitem>\r
488 <simpara>\r
489 40-hexdigit object name\r
490 </simpara>\r
491 </listitem>\r
492 <listitem>\r
493 <simpara>\r
494 branch name: refers to the commit at the head of the given\r
495           branch\r
496 </simpara>\r
497 </listitem>\r
498 <listitem>\r
499 <simpara>\r
500 tag name: refers to the commit pointed to by the given tag\r
501           (we've seen branches and tags are special cases of\r
502           <link linkend="Git User Manual_how-git-stores-references">references</link>).\r
503 </simpara>\r
504 </listitem>\r
505 <listitem>\r
506 <simpara>\r
507 HEAD: refers to the head of the current branch\r
508 </simpara>\r
509 </listitem>\r
510 </itemizedlist>\r
511 <simpara>There are many more; see the "SPECIFYING REVISIONS" section of the\r
512 <xref linkend="gitrevisions(7)" /> man page for the complete list of ways to\r
513 name revisions.  Some examples:</simpara>\r
514 <literallayout>$ git show fb47ddb2 # the first few characters of the object name\r
515                     # are usually enough to specify it uniquely\r
516 $ git show HEAD^    # the parent of the HEAD commit\r
517 $ git show HEAD^^   # the grandparent\r
518 $ git show HEAD~4   # the great-great-grandparent</literallayout>\r
519 <simpara>Recall that merge commits may have more than one parent; by default,\r
520 <emphasis>^</emphasis> and <emphasis>~</emphasis> follow the first parent listed in the commit, but you can\r
521 also choose:</simpara>\r
522 <literallayout>$ git show HEAD^1   # show the first parent of HEAD\r
523 $ git show HEAD^2   # show the second parent of HEAD</literallayout>\r
524 <simpara>In addition to HEAD, there are several other special names for\r
525 commits:</simpara>\r
526 <simpara>Merges (to be discussed later), as well as operations such as\r
527 <emphasis>git reset</emphasis>, which change the currently checked-out commit, generally\r
528 set ORIG_HEAD to the value HEAD had before the current operation.</simpara>\r
529 <simpara>The <emphasis>git fetch</emphasis> operation always stores the head of the last fetched\r
530 branch in FETCH_HEAD.  For example, if you run <emphasis>git fetch</emphasis> without\r
531 specifying a local branch as the target of the operation</simpara>\r
532 <literallayout>$ git fetch git://example.com/proj.git theirbranch</literallayout>\r
533 <simpara>the fetched commits will still be available from FETCH_HEAD.</simpara>\r
534 <simpara>When we discuss merges we'll also see the special name MERGE_HEAD,\r
535 which refers to the other branch that we're merging in to the current\r
536 branch.</simpara>\r
537 <simpara>The <xref linkend="git-rev-parse(1)" /> command is a low-level command that is\r
538 occasionally useful for translating some name for a commit to the object\r
539 name for that commit:</simpara>\r
540 <literallayout>$ git rev-parse origin\r
541 e05db0fd4f31dde7005f075a84f96b360d05984b</literallayout>\r
542 </section>\r
543 <section id="Git User Manual_creating-tags">\r
544 <title>Creating tags</title>\r
545 <simpara>We can also create a tag to refer to a particular commit; after\r
546 running</simpara>\r
547 <literallayout>$ git tag stable-1 1b2e1d63ff</literallayout>\r
548 <simpara>You can use <emphasis>stable-1</emphasis> to refer to the commit 1b2e1d63ff.</simpara>\r
549 <simpara>This creates a "lightweight" tag.  If you would also like to include a\r
550 comment with the tag, and possibly sign it cryptographically, then you\r
551 should create a tag object instead; see the <xref linkend="git-tag(1)" /> man page\r
552 for details.</simpara>\r
553 </section>\r
554 <section id="Git User Manual_browsing-revisions">\r
555 <title>Browsing revisions</title>\r
556 <simpara>The <xref linkend="git-log(1)" /> command can show lists of commits.  On its\r
557 own, it shows all commits reachable from the parent commit; but you\r
558 can also make more specific requests:</simpara>\r
559 <literallayout>$ git log v2.5..        # commits since (not reachable from) v2.5\r
560 $ git log test..master  # commits reachable from master but not test\r
561 $ git log master..test  # ...reachable from test but not master\r
562 $ git log master...test # ...reachable from either test or master,\r
563                         #    but not both\r
564 $ git log --since="2 weeks ago" # commits from the last 2 weeks\r
565 $ git log Makefile      # commits which modify Makefile\r
566 $ git log fs/           # ... which modify any file under fs/\r
567 $ git log -S'foo()'     # commits which add or remove any file data\r
568                         # matching the string 'foo()'</literallayout>\r
569 <simpara>And of course you can combine all of these; the following finds\r
570 commits since v2.5 which touch the <emphasis>Makefile</emphasis> or any file under <emphasis>fs</emphasis>:</simpara>\r
571 <literallayout>$ git log v2.5.. Makefile fs/</literallayout>\r
572 <simpara>You can also ask git log to show patches:</simpara>\r
573 <literallayout>$ git log -p</literallayout>\r
574 <simpara>See the <emphasis>--pretty</emphasis> option in the <xref linkend="git-log(1)" /> man page for more\r
575 display options.</simpara>\r
576 <simpara>Note that git log starts with the most recent commit and works\r
577 backwards through the parents; however, since Git history can contain\r
578 multiple independent lines of development, the particular order that\r
579 commits are listed in may be somewhat arbitrary.</simpara>\r
580 </section>\r
581 <section id="Git User Manual_generating-diffs">\r
582 <title>Generating diffs</title>\r
583 <simpara>You can generate diffs between any two versions using\r
584 <xref linkend="git-diff(1)" />:</simpara>\r
585 <literallayout>$ git diff master..test</literallayout>\r
586 <simpara>That will produce the diff between the tips of the two branches.  If\r
587 you'd prefer to find the diff from their common ancestor to test, you\r
588 can use three dots instead of two:</simpara>\r
589 <literallayout>$ git diff master...test</literallayout>\r
590 <simpara>Sometimes what you want instead is a set of patches; for this you can\r
591 use <xref linkend="git-format-patch(1)" />:</simpara>\r
592 <literallayout>$ git format-patch master..test</literallayout>\r
593 <simpara>will generate a file with a patch for each commit reachable from test\r
594 but not from master.</simpara>\r
595 </section>\r
596 <section id="Git User Manual_viewing-old-file-versions">\r
597 <title>Viewing old file versions</title>\r
598 <simpara>You can always view an old version of a file by just checking out the\r
599 correct revision first.  But sometimes it is more convenient to be\r
600 able to view an old version of a single file without checking\r
601 anything out; this command does that:</simpara>\r
602 <literallayout>$ git show v2.5:fs/locks.c</literallayout>\r
603 <simpara>Before the colon may be anything that names a commit, and after it\r
604 may be any path to a file tracked by Git.</simpara>\r
605 </section>\r
606 <section id="Git User Manual_history-examples">\r
607 <title>Examples</title>\r
608 <section id="Git User Manual_counting-commits-on-a-branch">\r
609 <title>Counting the number of commits on a branch</title>\r
610 <simpara>Suppose you want to know how many commits you've made on <emphasis>mybranch</emphasis>\r
611 since it diverged from <emphasis>origin</emphasis>:</simpara>\r
612 <literallayout>$ git log --pretty=oneline origin..mybranch | wc -l</literallayout>\r
613 <simpara>Alternatively, you may often see this sort of thing done with the\r
614 lower-level command <xref linkend="git-rev-list(1)" />, which just lists the SHA-1's\r
615 of all the given commits:</simpara>\r
616 <literallayout>$ git rev-list origin..mybranch | wc -l</literallayout>\r
617 </section>\r
618 <section id="Git User Manual_checking-for-equal-branches">\r
619 <title>Check whether two branches point at the same history</title>\r
620 <simpara>Suppose you want to check whether two branches point at the same point\r
621 in history.</simpara>\r
622 <literallayout>$ git diff origin..master</literallayout>\r
623 <simpara>will tell you whether the contents of the project are the same at the\r
624 two branches; in theory, however, it's possible that the same project\r
625 contents could have been arrived at by two different historical\r
626 routes.  You could compare the object names:</simpara>\r
627 <literallayout>$ git rev-list origin\r
628 e05db0fd4f31dde7005f075a84f96b360d05984b\r
629 $ git rev-list master\r
630 e05db0fd4f31dde7005f075a84f96b360d05984b</literallayout>\r
631 <simpara>Or you could recall that the <emphasis>...</emphasis> operator selects all commits\r
632 reachable from either one reference or the other but not\r
633 both; so</simpara>\r
634 <literallayout>$ git log origin...master</literallayout>\r
635 <simpara>will return no commits when the two branches are equal.</simpara>\r
636 </section>\r
637 <section id="Git User Manual_finding-tagged-descendants">\r
638 <title>Find first tagged version including a given fix</title>\r
639 <simpara>Suppose you know that the commit e05db0fd fixed a certain problem.\r
640 You'd like to find the earliest tagged release that contains that\r
641 fix.</simpara>\r
642 <simpara>Of course, there may be more than one answer--if the history branched\r
643 after commit e05db0fd, then there could be multiple "earliest" tagged\r
644 releases.</simpara>\r
645 <simpara>You could just visually inspect the commits since e05db0fd:</simpara>\r
646 <literallayout>$ gitk e05db0fd..</literallayout>\r
647 <simpara>or you can use <xref linkend="git-name-rev(1)" />, which will give the commit a\r
648 name based on any tag it finds pointing to one of the commit's\r
649 descendants:</simpara>\r
650 <literallayout>$ git name-rev --tags e05db0fd\r
651 e05db0fd tags/v1.5.0-rc1^0~23</literallayout>\r
652 <simpara>The <xref linkend="git-describe(1)" /> command does the opposite, naming the\r
653 revision using a tag on which the given commit is based:</simpara>\r
654 <literallayout>$ git describe e05db0fd\r
655 v1.5.0-rc0-260-ge05db0f</literallayout>\r
656 <simpara>but that may sometimes help you guess which tags might come after the\r
657 given commit.</simpara>\r
658 <simpara>If you just want to verify whether a given tagged version contains a\r
659 given commit, you could use <xref linkend="git-merge-base(1)" />:</simpara>\r
660 <literallayout>$ git merge-base e05db0fd v1.5.0-rc1\r
661 e05db0fd4f31dde7005f075a84f96b360d05984b</literallayout>\r
662 <simpara>The merge-base command finds a common ancestor of the given commits,\r
663 and always returns one or the other in the case where one is a\r
664 descendant of the other; so the above output shows that e05db0fd\r
665 actually is an ancestor of v1.5.0-rc1.</simpara>\r
666 <simpara>Alternatively, note that</simpara>\r
667 <literallayout>$ git log v1.5.0-rc1..e05db0fd</literallayout>\r
668 <simpara>will produce empty output if and only if v1.5.0-rc1 includes e05db0fd,\r
669 because it outputs only commits that are not reachable from v1.5.0-rc1.</simpara>\r
670 <simpara>As yet another alternative, the <xref linkend="git-show-branch(1)" /> command lists\r
671 the commits reachable from its arguments with a display on the left-hand\r
672 side that indicates which arguments that commit is reachable from.\r
673 So, if you run something like</simpara>\r
674 <literallayout>$ git show-branch e05db0fd v1.5.0-rc0 v1.5.0-rc1 v1.5.0-rc2\r
675 ! [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if\r
676 available\r
677  ! [v1.5.0-rc0] GIT v1.5.0 preview\r
678   ! [v1.5.0-rc1] GIT v1.5.0-rc1\r
679    ! [v1.5.0-rc2] GIT v1.5.0-rc2\r
680 ...</literallayout>\r
681 <simpara>then a line like</simpara>\r
682 <literallayout>+ ++ [e05db0fd] Fix warnings in sha1_file.c - use C99 printf format if\r
683 available</literallayout>\r
684 <simpara>shows that e05db0fd is reachable from itself, from v1.5.0-rc1,\r
685 and from v1.5.0-rc2, and not from v1.5.0-rc0.</simpara>\r
686 </section>\r
687 <section id="Git User Manual_showing-commits-unique-to-a-branch">\r
688 <title>Showing commits unique to a given branch</title>\r
689 <simpara>Suppose you would like to see all the commits reachable from the branch\r
690 head named <emphasis>master</emphasis> but not from any other head in your repository.</simpara>\r
691 <simpara>We can list all the heads in this repository with\r
692 <xref linkend="git-show-ref(1)" />:</simpara>\r
693 <literallayout>$ git show-ref --heads\r
694 bf62196b5e363d73353a9dcf094c59595f3153b7 refs/heads/core-tutorial\r
695 db768d5504c1bb46f63ee9d6e1772bd047e05bf9 refs/heads/maint\r
696 a07157ac624b2524a059a3414e99f6f44bebc1e7 refs/heads/master\r
697 24dbc180ea14dc1aebe09f14c8ecf32010690627 refs/heads/tutorial-2\r
698 1e87486ae06626c2f31eaa63d26fc0fd646c8af2 refs/heads/tutorial-fixes</literallayout>\r
699 <simpara>We can get just the branch-head names, and remove <emphasis>master</emphasis>, with\r
700 the help of the standard utilities cut and grep:</simpara>\r
701 <literallayout>$ git show-ref --heads | cut -d' ' -f2 | grep -v '^refs/heads/master'\r
702 refs/heads/core-tutorial\r
703 refs/heads/maint\r
704 refs/heads/tutorial-2\r
705 refs/heads/tutorial-fixes</literallayout>\r
706 <simpara>And then we can ask to see all the commits reachable from master\r
707 but not from these other heads:</simpara>\r
708 <literallayout>$ gitk master --not $( git show-ref --heads | cut -d' ' -f2 |\r
709                                 grep -v '^refs/heads/master' )</literallayout>\r
710 <simpara>Obviously, endless variations are possible; for example, to see all\r
711 commits reachable from some head but not from any tag in the repository:</simpara>\r
712 <literallayout>$ gitk $( git show-ref --heads ) --not  $( git show-ref --tags )</literallayout>\r
713 <simpara>(See <xref linkend="gitrevisions(7)" /> for explanations of commit-selecting\r
714 syntax such as <emphasis>--not</emphasis>.)</simpara>\r
715 </section>\r
716 <section id="Git User Manual_making-a-release">\r
717 <title>Creating a changelog and tarball for a software release</title>\r
718 <simpara>The <xref linkend="git-archive(1)" /> command can create a tar or zip archive from\r
719 any version of a project; for example:</simpara>\r
720 <literallayout>$ git archive -o latest.tar.gz --prefix=project/ HEAD</literallayout>\r
721 <simpara>will use HEAD to produce a gzipped tar archive in which each filename\r
722 is preceded by <emphasis>project/</emphasis>.  The output file format is inferred from\r
723 the output file extension if possible, see <xref linkend="git-archive(1)" /> for\r
724 details.</simpara>\r
725 <simpara>Versions of Git older than 1.7.7 don't know about the <emphasis>tar.gz</emphasis> format,\r
726 you'll need to use gzip explicitly:</simpara>\r
727 <literallayout>$ git archive --format=tar --prefix=project/ HEAD | gzip &gt;latest.tar.gz</literallayout>\r
728 <simpara>If you're releasing a new version of a software project, you may want\r
729 to simultaneously make a changelog to include in the release\r
730 announcement.</simpara>\r
731 <simpara>Linus Torvalds, for example, makes new kernel releases by tagging them,\r
732 then running:</simpara>\r
733 <literallayout>$ release-script 2.6.12 2.6.13-rc6 2.6.13-rc7</literallayout>\r
734 <simpara>where release-script is a shell script that looks like:</simpara>\r
735 <literallayout>#!/bin/sh\r
736 stable="$1"\r
737 last="$2"\r
738 new="$3"\r
739 echo "# git tag v$new"\r
740 echo "git archive --prefix=linux-$new/ v$new | gzip -9 &gt; ../linux-$new.tar.gz"\r
741 echo "git diff v$stable v$new | gzip -9 &gt; ../patch-$new.gz"\r
742 echo "git log --no-merges v$new ^v$last &gt; ../ChangeLog-$new"\r
743 echo "git shortlog --no-merges v$new ^v$last &gt; ../ShortLog"\r
744 echo "git diff --stat --summary -M v$last v$new &gt; ../diffstat-$new"</literallayout>\r
745 <simpara>and then he just cut-and-pastes the output commands after verifying that\r
746 they look OK.</simpara>\r
747 </section>\r
748 <section id="Git User Manual_Finding-commits-With-given-Content">\r
749 <title>Finding commits referencing a file with given content</title>\r
750 <simpara>Somebody hands you a copy of a file, and asks which commits modified a\r
751 file such that it contained the given content either before or after the\r
752 commit.  You can find out with this:</simpara>\r
753 <literallayout>$  git log --raw --abbrev=40 --pretty=oneline |\r
754         grep -B 1 `git hash-object filename`</literallayout>\r
755 <simpara>Figuring out why this works is left as an exercise to the (advanced)\r
756 student.  The <xref linkend="git-log(1)" />, <xref linkend="git-diff-tree(1)" />, and\r
757 <xref linkend="git-hash-object(1)" /> man pages may prove helpful.</simpara>\r
758 </section>\r
759 </section>\r
760 </section>\r
761 <section id="Git User Manual_Developing-With-git">\r
762 <title>Developing with Git</title>\r
763 <section id="Git User Manual_telling-git-your-name">\r
764 <title>Telling Git your name</title>\r
765 <simpara>Before creating any commits, you should introduce yourself to Git.\r
766 The easiest way to do so is to use <xref linkend="git-config(1)" />:</simpara>\r
767 <literallayout>$ git config --global user.name 'Your Name Comes Here'\r
768 $ git config --global user.email 'you@yourdomain.example.com'</literallayout>\r
769 <simpara>Which will add the following to a file named <emphasis>.gitconfig</emphasis> in your\r
770 home directory:</simpara>\r
771 <literallayout>[user]\r
772         name = Your Name Comes Here\r
773         email = you@yourdomain.example.com</literallayout>\r
774 <simpara>See the "CONFIGURATION FILE" section of <xref linkend="git-config(1)" /> for\r
775 details on the configuration file.  The file is plain text, so you can\r
776 also edit it with your favorite editor.</simpara>\r
777 </section>\r
778 <section id="Git User Manual_creating-a-new-repository">\r
779 <title>Creating a new repository</title>\r
780 <simpara>Creating a new repository from scratch is very easy:</simpara>\r
781 <literallayout>$ mkdir project\r
782 $ cd project\r
783 $ git init</literallayout>\r
784 <simpara>If you have some initial content (say, a tarball):</simpara>\r
785 <literallayout>$ tar xzvf project.tar.gz\r
786 $ cd project\r
787 $ git init\r
788 $ git add . # include everything below ./ in the first commit:\r
789 $ git commit</literallayout>\r
790 </section>\r
791 <section id="Git User Manual_how-to-make-a-commit">\r
792 <title>How to make a commit</title>\r
793 <simpara>Creating a new commit takes three steps:</simpara>\r
794 <orderedlist numeration="arabic">\r
795 <listitem>\r
796 <simpara>\r
797 Making some changes to the working directory using your\r
798            favorite editor.\r
799 </simpara>\r
800 </listitem>\r
801 <listitem>\r
802 <simpara>\r
803 Telling Git about your changes.\r
804 </simpara>\r
805 </listitem>\r
806 <listitem>\r
807 <simpara>\r
808 Creating the commit using the content you told Git about\r
809            in step 2.\r
810 </simpara>\r
811 </listitem>\r
812 </orderedlist>\r
813 <simpara>In practice, you can interleave and repeat steps 1 and 2 as many\r
814 times as you want: in order to keep track of what you want committed\r
815 at step 3, Git maintains a snapshot of the tree's contents in a\r
816 special staging area called "the index."</simpara>\r
817 <simpara>At the beginning, the content of the index will be identical to\r
818 that of the HEAD.  The command <emphasis>git diff --cached</emphasis>, which shows\r
819 the difference between the HEAD and the index, should therefore\r
820 produce no output at that point.</simpara>\r
821 <simpara>Modifying the index is easy:</simpara>\r
822 <simpara>To update the index with the contents of a new or modified file, use</simpara>\r
823 <literallayout>$ git add path/to/file</literallayout>\r
824 <simpara>To remove a file from the index and from the working tree, use</simpara>\r
825 <literallayout>$ git rm path/to/file</literallayout>\r
826 <simpara>After each step you can verify that</simpara>\r
827 <literallayout>$ git diff --cached</literallayout>\r
828 <simpara>always shows the difference between the HEAD and the index file--this\r
829 is what you'd commit if you created the commit now--and that</simpara>\r
830 <literallayout>$ git diff</literallayout>\r
831 <simpara>shows the difference between the working tree and the index file.</simpara>\r
832 <simpara>Note that <emphasis>git add</emphasis> always adds just the current contents of a file\r
833 to the index; further changes to the same file will be ignored unless\r
834 you run <emphasis>git add</emphasis> on the file again.</simpara>\r
835 <simpara>When you're ready, just run</simpara>\r
836 <literallayout>$ git commit</literallayout>\r
837 <simpara>and Git will prompt you for a commit message and then create the new\r
838 commit.  Check to make sure it looks like what you expected with</simpara>\r
839 <literallayout>$ git show</literallayout>\r
840 <simpara>As a special shortcut,</simpara>\r
841 <literallayout>$ git commit -a</literallayout>\r
842 <simpara>will update the index with any files that you've modified or removed\r
843 and create a commit, all in one step.</simpara>\r
844 <simpara>A number of commands are useful for keeping track of what you're\r
845 about to commit:</simpara>\r
846 <literallayout>$ git diff --cached # difference between HEAD and the index; what\r
847                     # would be committed if you ran "commit" now.\r
848 $ git diff          # difference between the index file and your\r
849                     # working directory; changes that would not\r
850                     # be included if you ran "commit" now.\r
851 $ git diff HEAD     # difference between HEAD and working tree; what\r
852                     # would be committed if you ran "commit -a" now.\r
853 $ git status        # a brief per-file summary of the above.</literallayout>\r
854 <simpara>You can also use <xref linkend="git-gui(1)" /> to create commits, view changes in\r
855 the index and the working tree files, and individually select diff hunks\r
856 for inclusion in the index (by right-clicking on the diff hunk and\r
857 choosing "Stage Hunk For Commit").</simpara>\r
858 </section>\r
859 <section id="Git User Manual_creating-good-commit-messages">\r
860 <title>Creating good commit messages</title>\r
861 <simpara>Though not required, it's a good idea to begin the commit message\r
862 with a single short (less than 50 character) line summarizing the\r
863 change, followed by a blank line and then a more thorough\r
864 description.  The text up to the first blank line in a commit\r
865 message is treated as the commit title, and that title is used\r
866 throughout Git.  For example, <xref linkend="git-format-patch(1)" /> turns a\r
867 commit into email, and it uses the title on the Subject line and the\r
868 rest of the commit in the body.</simpara>\r
869 </section>\r
870 <section id="Git User Manual_ignoring-files">\r
871 <title>Ignoring files</title>\r
872 <simpara>A project will often generate files that you do <emphasis>not</emphasis> want to track with Git.\r
873 This typically includes files generated by a build process or temporary\r
874 backup files made by your editor. Of course, <emphasis>not</emphasis> tracking files with Git\r
875 is just a matter of <emphasis>not</emphasis> calling <emphasis>git add</emphasis> on them. But it quickly becomes\r
876 annoying to have these untracked files lying around; e.g. they make\r
877 <emphasis>git add .</emphasis> practically useless, and they keep showing up in the output of\r
878 <emphasis>git status</emphasis>.</simpara>\r
879 <simpara>You can tell Git to ignore certain files by creating a file called\r
880 <emphasis>.gitignore</emphasis> in the top level of your working directory, with contents\r
881 such as:</simpara>\r
882 <literallayout># Lines starting with '#' are considered comments.\r
883 # Ignore any file named foo.txt.\r
884 foo.txt\r
885 # Ignore (generated) html files,\r
886 *.html\r
887 # except foo.html which is maintained by hand.\r
888 !foo.html\r
889 # Ignore objects and archives.\r
890 *.[oa]</literallayout>\r
891 <simpara>See <xref linkend="gitignore(5)" /> for a detailed explanation of the syntax.  You can\r
892 also place .gitignore files in other directories in your working tree, and they\r
893 will apply to those directories and their subdirectories.  The <emphasis>.gitignore</emphasis>\r
894 files can be added to your repository like any other files (just run <emphasis>git add\r
895 .gitignore</emphasis> and <emphasis>git commit</emphasis>, as usual), which is convenient when the exclude\r
896 patterns (such as patterns matching build output files) would also make sense\r
897 for other users who clone your repository.</simpara>\r
898 <simpara>If you wish the exclude patterns to affect only certain repositories\r
899 (instead of every repository for a given project), you may instead put\r
900 them in a file in your repository named <emphasis>.git/info/exclude</emphasis>, or in any\r
901 file specified by the <emphasis>core.excludesFile</emphasis> configuration variable.\r
902 Some Git commands can also take exclude patterns directly on the\r
903 command line.  See <xref linkend="gitignore(5)" /> for the details.</simpara>\r
904 </section>\r
905 <section id="Git User Manual_how-to-merge">\r
906 <title>How to merge</title>\r
907 <simpara>You can rejoin two diverging branches of development using\r
908 <xref linkend="git-merge(1)" />:</simpara>\r
909 <literallayout>$ git merge branchname</literallayout>\r
910 <simpara>merges the development in the branch <emphasis>branchname</emphasis> into the current\r
911 branch.</simpara>\r
912 <simpara>A merge is made by combining the changes made in <emphasis>branchname</emphasis> and the\r
913 changes made up to the latest commit in your current branch since\r
914 their histories forked. The work tree is overwritten by the result of\r
915 the merge when this combining is done cleanly, or overwritten by a\r
916 half-merged results when this combining results in conflicts.\r
917 Therefore, if you have uncommitted changes touching the same files as\r
918 the ones impacted by the merge, Git will refuse to proceed. Most of\r
919 the time, you will want to commit your changes before you can merge,\r
920 and if you don't, then <xref linkend="git-stash(1)" /> can take these changes\r
921 away while you're doing the merge, and reapply them afterwards.</simpara>\r
922 <simpara>If the changes are independent enough, Git will automatically complete\r
923 the merge and commit the result (or reuse an existing commit in case\r
924 of <link linkend="Git User Manual_fast-forwards">fast-forward</link>, see below). On the other hand,\r
925 if there are conflicts--for example, if the same file is\r
926 modified in two different ways in the remote branch and the local\r
927 branch--then you are warned; the output may look something like this:</simpara>\r
928 <literallayout>$ git merge next\r
929  100% (4/4) done\r
930 Auto-merged file.txt\r
931 CONFLICT (content): Merge conflict in file.txt\r
932 Automatic merge failed; fix conflicts and then commit the result.</literallayout>\r
933 <simpara>Conflict markers are left in the problematic files, and after\r
934 you resolve the conflicts manually, you can update the index\r
935 with the contents and run Git commit, as you normally would when\r
936 creating a new file.</simpara>\r
937 <simpara>If you examine the resulting commit using gitk, you will see that it\r
938 has two parents, one pointing to the top of the current branch, and\r
939 one to the top of the other branch.</simpara>\r
940 </section>\r
941 <section id="Git User Manual_resolving-a-merge">\r
942 <title>Resolving a merge</title>\r
943 <simpara>When a merge isn't resolved automatically, Git leaves the index and\r
944 the working tree in a special state that gives you all the\r
945 information you need to help resolve the merge.</simpara>\r
946 <simpara>Files with conflicts are marked specially in the index, so until you\r
947 resolve the problem and update the index, <xref linkend="git-commit(1)" /> will\r
948 fail:</simpara>\r
949 <literallayout>$ git commit\r
950 file.txt: needs merge</literallayout>\r
951 <simpara>Also, <xref linkend="git-status(1)" /> will list those files as "unmerged", and the\r
952 files with conflicts will have conflict markers added, like this:</simpara>\r
953 <literallayout>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD:file.txt\r
954 Hello world\r
955 =======\r
956 Goodbye\r
957 &gt;&gt;&gt;&gt;&gt;&gt;&gt; 77976da35a11db4580b80ae27e8d65caf5208086:file.txt</literallayout>\r
958 <simpara>All you need to do is edit the files to resolve the conflicts, and then</simpara>\r
959 <literallayout>$ git add file.txt\r
960 $ git commit</literallayout>\r
961 <simpara>Note that the commit message will already be filled in for you with\r
962 some information about the merge.  Normally you can just use this\r
963 default message unchanged, but you may add additional commentary of\r
964 your own if desired.</simpara>\r
965 <simpara>The above is all you need to know to resolve a simple merge.  But Git\r
966 also provides more information to help resolve conflicts:</simpara>\r
967 <section id="Git User Manual_conflict-resolution">\r
968 <title>Getting conflict-resolution help during a merge</title>\r
969 <simpara>All of the changes that Git was able to merge automatically are\r
970 already added to the index file, so <xref linkend="git-diff(1)" /> shows only\r
971 the conflicts.  It uses an unusual syntax:</simpara>\r
972 <literallayout>$ git diff\r
973 diff --cc file.txt\r
974 index 802992c,2b60207..0000000\r
975 --- a/file.txt\r
976 +++ b/file.txt\r
977 @@@ -1,1 -1,1 +1,5 @@@\r
978 ++&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD:file.txt\r
979  +Hello world\r
980 ++=======\r
981 + Goodbye\r
982 ++&gt;&gt;&gt;&gt;&gt;&gt;&gt; 77976da35a11db4580b80ae27e8d65caf5208086:file.txt</literallayout>\r
983 <simpara>Recall that the commit which will be committed after we resolve this\r
984 conflict will have two parents instead of the usual one: one parent\r
985 will be HEAD, the tip of the current branch; the other will be the\r
986 tip of the other branch, which is stored temporarily in MERGE_HEAD.</simpara>\r
987 <simpara>During the merge, the index holds three versions of each file.  Each of\r
988 these three "file stages" represents a different version of the file:</simpara>\r
989 <literallayout>$ git show :1:file.txt  # the file in a common ancestor of both branches\r
990 $ git show :2:file.txt  # the version from HEAD.\r
991 $ git show :3:file.txt  # the version from MERGE_HEAD.</literallayout>\r
992 <simpara>When you ask <xref linkend="git-diff(1)" /> to show the conflicts, it runs a\r
993 three-way diff between the conflicted merge results in the work tree with\r
994 stages 2 and 3 to show only hunks whose contents come from both sides,\r
995 mixed (in other words, when a hunk's merge results come only from stage 2,\r
996 that part is not conflicting and is not shown.  Same for stage 3).</simpara>\r
997 <simpara>The diff above shows the differences between the working-tree version of\r
998 file.txt and the stage 2 and stage 3 versions.  So instead of preceding\r
999 each line by a single <emphasis>+</emphasis> or <emphasis>-</emphasis>, it now uses two columns: the first\r
1000 column is used for differences between the first parent and the working\r
1001 directory copy, and the second for differences between the second parent\r
1002 and the working directory copy.  (See the "COMBINED DIFF FORMAT" section\r
1003 of <xref linkend="git-diff-files(1)" /> for a details of the format.)</simpara>\r
1004 <simpara>After resolving the conflict in the obvious way (but before updating the\r
1005 index), the diff will look like:</simpara>\r
1006 <literallayout>$ git diff\r
1007 diff --cc file.txt\r
1008 index 802992c,2b60207..0000000\r
1009 --- a/file.txt\r
1010 +++ b/file.txt\r
1011 @@@ -1,1 -1,1 +1,1 @@@\r
1012 - Hello world\r
1013  -Goodbye\r
1014 ++Goodbye world</literallayout>\r
1015 <simpara>This shows that our resolved version deleted "Hello world" from the\r
1016 first parent, deleted "Goodbye" from the second parent, and added\r
1017 "Goodbye world", which was previously absent from both.</simpara>\r
1018 <simpara>Some special diff options allow diffing the working directory against\r
1019 any of these stages:</simpara>\r
1020 <literallayout>$ git diff -1 file.txt          # diff against stage 1\r
1021 $ git diff --base file.txt      # same as the above\r
1022 $ git diff -2 file.txt          # diff against stage 2\r
1023 $ git diff --ours file.txt      # same as the above\r
1024 $ git diff -3 file.txt          # diff against stage 3\r
1025 $ git diff --theirs file.txt    # same as the above.</literallayout>\r
1026 <simpara>The <xref linkend="git-log(1)" /> and <xref linkend="gitk(1)" /> commands also provide special help\r
1027 for merges:</simpara>\r
1028 <literallayout>$ git log --merge\r
1029 $ gitk --merge</literallayout>\r
1030 <simpara>These will display all commits which exist only on HEAD or on\r
1031 MERGE_HEAD, and which touch an unmerged file.</simpara>\r
1032 <simpara>You may also use <xref linkend="git-mergetool(1)" />, which lets you merge the\r
1033 unmerged files using external tools such as Emacs or kdiff3.</simpara>\r
1034 <simpara>Each time you resolve the conflicts in a file and update the index:</simpara>\r
1035 <literallayout>$ git add file.txt</literallayout>\r
1036 <simpara>the different stages of that file will be "collapsed", after which\r
1037 <emphasis>git diff</emphasis> will (by default) no longer show diffs for that file.</simpara>\r
1038 </section>\r
1039 </section>\r
1040 <section id="Git User Manual_undoing-a-merge">\r
1041 <title>Undoing a merge</title>\r
1042 <simpara>If you get stuck and decide to just give up and throw the whole mess\r
1043 away, you can always return to the pre-merge state with</simpara>\r
1044 <literallayout>$ git reset --hard HEAD</literallayout>\r
1045 <simpara>Or, if you've already committed the merge that you want to throw away,</simpara>\r
1046 <literallayout>$ git reset --hard ORIG_HEAD</literallayout>\r
1047 <simpara>However, this last command can be dangerous in some cases--never\r
1048 throw away a commit you have already committed if that commit may\r
1049 itself have been merged into another branch, as doing so may confuse\r
1050 further merges.</simpara>\r
1051 </section>\r
1052 <section id="Git User Manual_fast-forwards">\r
1053 <title>Fast-forward merges</title>\r
1054 <simpara>There is one special case not mentioned above, which is treated\r
1055 differently.  Normally, a merge results in a merge commit, with two\r
1056 parents, one pointing at each of the two lines of development that\r
1057 were merged.</simpara>\r
1058 <simpara>However, if the current branch is an ancestor of the other--so every commit\r
1059 present in the current branch is already contained in the other branch--then Git\r
1060 just performs a "fast-forward"; the head of the current branch is moved forward\r
1061 to point at the head of the merged-in branch, without any new commits being\r
1062 created.</simpara>\r
1063 </section>\r
1064 <section id="Git User Manual_fixing-mistakes">\r
1065 <title>Fixing mistakes</title>\r
1066 <simpara>If you've messed up the working tree, but haven't yet committed your\r
1067 mistake, you can return the entire working tree to the last committed\r
1068 state with</simpara>\r
1069 <literallayout>$ git reset --hard HEAD</literallayout>\r
1070 <simpara>If you make a commit that you later wish you hadn't, there are two\r
1071 fundamentally different ways to fix the problem:</simpara>\r
1072 <orderedlist numeration="arabic">\r
1073 <listitem>\r
1074 <simpara>\r
1075 You can create a new commit that undoes whatever was done\r
1076         by the old commit.  This is the correct thing if your\r
1077         mistake has already been made public.\r
1078 </simpara>\r
1079 </listitem>\r
1080 <listitem>\r
1081 <simpara>\r
1082 You can go back and modify the old commit.  You should\r
1083         never do this if you have already made the history public;\r
1084         Git does not normally expect the "history" of a project to\r
1085         change, and cannot correctly perform repeated merges from\r
1086         a branch that has had its history changed.\r
1087 </simpara>\r
1088 </listitem>\r
1089 </orderedlist>\r
1090 <section id="Git User Manual_reverting-a-commit">\r
1091 <title>Fixing a mistake with a new commit</title>\r
1092 <simpara>Creating a new commit that reverts an earlier change is very easy;\r
1093 just pass the <xref linkend="git-revert(1)" /> command a reference to the bad\r
1094 commit; for example, to revert the most recent commit:</simpara>\r
1095 <literallayout>$ git revert HEAD</literallayout>\r
1096 <simpara>This will create a new commit which undoes the change in HEAD.  You\r
1097 will be given a chance to edit the commit message for the new commit.</simpara>\r
1098 <simpara>You can also revert an earlier change, for example, the next-to-last:</simpara>\r
1099 <literallayout>$ git revert HEAD^</literallayout>\r
1100 <simpara>In this case Git will attempt to undo the old change while leaving\r
1101 intact any changes made since then.  If more recent changes overlap\r
1102 with the changes to be reverted, then you will be asked to fix\r
1103 conflicts manually, just as in the case of <link linkend="Git User Manual_resolving-a-merge">resolving a merge</link>.</simpara>\r
1104 </section>\r
1105 <section id="Git User Manual_fixing-a-mistake-by-rewriting-history">\r
1106 <title>Fixing a mistake by rewriting history</title>\r
1107 <simpara>If the problematic commit is the most recent commit, and you have not\r
1108 yet made that commit public, then you may just\r
1109 <link linkend="Git User Manual_undoing-a-merge">destroy it using <emphasis>git reset</emphasis></link>.</simpara>\r
1110 <simpara>Alternatively, you\r
1111 can edit the working directory and update the index to fix your\r
1112 mistake, just as if you were going to <link linkend="Git User Manual_how-to-make-a-commit">create a new commit</link>, then run</simpara>\r
1113 <literallayout>$ git commit --amend</literallayout>\r
1114 <simpara>which will replace the old commit by a new commit incorporating your\r
1115 changes, giving you a chance to edit the old commit message first.</simpara>\r
1116 <simpara>Again, you should never do this to a commit that may already have\r
1117 been merged into another branch; use <xref linkend="git-revert(1)" /> instead in\r
1118 that case.</simpara>\r
1119 <simpara>It is also possible to replace commits further back in the history, but\r
1120 this is an advanced topic to be left for\r
1121 <link linkend="Git User Manual_cleaning-up-history">another chapter</link>.</simpara>\r
1122 </section>\r
1123 <section id="Git User Manual_checkout-of-path">\r
1124 <title>Checking out an old version of a file</title>\r
1125 <simpara>In the process of undoing a previous bad change, you may find it\r
1126 useful to check out an older version of a particular file using\r
1127 <xref linkend="git-checkout(1)" />.  We've used <emphasis>git checkout</emphasis> before to switch\r
1128 branches, but it has quite different behavior if it is given a path\r
1129 name: the command</simpara>\r
1130 <literallayout>$ git checkout HEAD^ path/to/file</literallayout>\r
1131 <simpara>replaces path/to/file by the contents it had in the commit HEAD^, and\r
1132 also updates the index to match.  It does not change branches.</simpara>\r
1133 <simpara>If you just want to look at an old version of the file, without\r
1134 modifying the working directory, you can do that with\r
1135 <xref linkend="git-show(1)" />:</simpara>\r
1136 <literallayout>$ git show HEAD^:path/to/file</literallayout>\r
1137 <simpara>which will display the given version of the file.</simpara>\r
1138 </section>\r
1139 <section id="Git User Manual_interrupted-work">\r
1140 <title>Temporarily setting aside work in progress</title>\r
1141 <simpara>While you are in the middle of working on something complicated, you\r
1142 find an unrelated but obvious and trivial bug.  You would like to fix it\r
1143 before continuing.  You can use <xref linkend="git-stash(1)" /> to save the current\r
1144 state of your work, and after fixing the bug (or, optionally after doing\r
1145 so on a different branch and then coming back), unstash the\r
1146 work-in-progress changes.</simpara>\r
1147 <literallayout>$ git stash save "work in progress for foo feature"</literallayout>\r
1148 <simpara>This command will save your changes away to the <emphasis>stash</emphasis>, and\r
1149 reset your working tree and the index to match the tip of your\r
1150 current branch.  Then you can make your fix as usual.</simpara>\r
1151 <literallayout>... edit and test ...\r
1152 $ git commit -a -m "blorpl: typofix"</literallayout>\r
1153 <simpara>After that, you can go back to what you were working on with\r
1154 <emphasis>git stash pop</emphasis>:</simpara>\r
1155 <literallayout>$ git stash pop</literallayout>\r
1156 </section>\r
1157 </section>\r
1158 <section id="Git User Manual_ensuring-good-performance">\r
1159 <title>Ensuring good performance</title>\r
1160 <simpara>On large repositories, Git depends on compression to keep the history\r
1161 information from taking up too much space on disk or in memory.  Some\r
1162 Git commands may automatically run <xref linkend="git-gc(1)" />, so you don't\r
1163 have to worry about running it manually.  However, compressing a large\r
1164 repository may take a while, so you may want to call <emphasis>gc</emphasis> explicitly\r
1165 to avoid automatic compression kicking in when it is not convenient.</simpara>\r
1166 </section>\r
1167 <section id="Git User Manual_ensuring-reliability">\r
1168 <title>Ensuring reliability</title>\r
1169 <section id="Git User Manual_checking-for-corruption">\r
1170 <title>Checking the repository for corruption</title>\r
1171 <simpara>The <xref linkend="git-fsck(1)" /> command runs a number of self-consistency checks\r
1172 on the repository, and reports on any problems.  This may take some\r
1173 time.</simpara>\r
1174 <literallayout>$ git fsck\r
1175 dangling commit 7281251ddd2a61e38657c827739c57015671a6b3\r
1176 dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63\r
1177 dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5\r
1178 dangling blob 218761f9d90712d37a9c5e36f406f92202db07eb\r
1179 dangling commit bf093535a34a4d35731aa2bd90fe6b176302f14f\r
1180 dangling commit 8e4bec7f2ddaa268bef999853c25755452100f8e\r
1181 dangling tree d50bb86186bf27b681d25af89d3b5b68382e4085\r
1182 dangling tree b24c2473f1fd3d91352a624795be026d64c8841f\r
1183 ...</literallayout>\r
1184 <simpara>You will see informational messages on dangling objects. They are objects\r
1185 that still exist in the repository but are no longer referenced by any of\r
1186 your branches, and can (and will) be removed after a while with <emphasis>gc</emphasis>.\r
1187 You can run <emphasis>git fsck --no-dangling</emphasis> to suppress these messages, and still\r
1188 view real errors.</simpara>\r
1189 </section>\r
1190 <section id="Git User Manual_recovering-lost-changes">\r
1191 <title>Recovering lost changes</title>\r
1192 <section id="reflogs">\r
1193 <title>Reflogs</title>\r
1194 <simpara>Say you modify a branch with <link linkend="Git User Manual_fixing-mistakes"><emphasis>git reset --hard</emphasis></link>,\r
1195 and then realize that the branch was the only reference you had to\r
1196 that point in history.</simpara>\r
1197 <simpara>Fortunately, Git also keeps a log, called a "reflog", of all the\r
1198 previous values of each branch.  So in this case you can still find the\r
1199 old history using, for example,</simpara>\r
1200 <literallayout>$ git log master@{1}</literallayout>\r
1201 <simpara>This lists the commits reachable from the previous version of the\r
1202 <emphasis>master</emphasis> branch head.  This syntax can be used with any Git command\r
1203 that accepts a commit, not just with <emphasis>git log</emphasis>.  Some other examples:</simpara>\r
1204 <literallayout>$ git show master@{2}           # See where the branch pointed 2,\r
1205 $ git show master@{3}           # 3, ... changes ago.\r
1206 $ gitk master@{yesterday}       # See where it pointed yesterday,\r
1207 $ gitk master@{"1 week ago"}    # ... or last week\r
1208 $ git log --walk-reflogs master # show reflog entries for master</literallayout>\r
1209 <simpara>A separate reflog is kept for the HEAD, so</simpara>\r
1210 <literallayout>$ git show HEAD@{"1 week ago"}</literallayout>\r
1211 <simpara>will show what HEAD pointed to one week ago, not what the current branch\r
1212 pointed to one week ago.  This allows you to see the history of what\r
1213 you've checked out.</simpara>\r
1214 <simpara>The reflogs are kept by default for 30 days, after which they may be\r
1215 pruned.  See <xref linkend="git-reflog(1)" /> and <xref linkend="git-gc(1)" /> to learn\r
1216 how to control this pruning, and see the "SPECIFYING REVISIONS"\r
1217 section of <xref linkend="gitrevisions(7)" /> for details.</simpara>\r
1218 <simpara>Note that the reflog history is very different from normal Git history.\r
1219 While normal history is shared by every repository that works on the\r
1220 same project, the reflog history is not shared: it tells you only about\r
1221 how the branches in your local repository have changed over time.</simpara>\r
1222 </section>\r
1223 <section id="dangling-object-recovery">\r
1224 <title>Examining dangling objects</title>\r
1225 <simpara>In some situations the reflog may not be able to save you.  For example,\r
1226 suppose you delete a branch, then realize you need the history it\r
1227 contained.  The reflog is also deleted; however, if you have not yet\r
1228 pruned the repository, then you may still be able to find the lost\r
1229 commits in the dangling objects that <emphasis>git fsck</emphasis> reports.  See\r
1230 <xref linkend="Git User Manual_dangling-objects"/> for the details.</simpara>\r
1231 <literallayout>$ git fsck\r
1232 dangling commit 7281251ddd2a61e38657c827739c57015671a6b3\r
1233 dangling commit 2706a059f258c6b245f298dc4ff2ccd30ec21a63\r
1234 dangling commit 13472b7c4b80851a1bc551779171dcb03655e9b5\r
1235 ...</literallayout>\r
1236 <simpara>You can examine\r
1237 one of those dangling commits with, for example,</simpara>\r
1238 <literallayout>$ gitk 7281251ddd --not --all</literallayout>\r
1239 <simpara>which does what it sounds like: it says that you want to see the commit\r
1240 history that is described by the dangling commit(s), but not the\r
1241 history that is described by all your existing branches and tags.  Thus\r
1242 you get exactly the history reachable from that commit that is lost.\r
1243 (And notice that it might not be just one commit: we only report the\r
1244 "tip of the line" as being dangling, but there might be a whole deep\r
1245 and complex commit history that was dropped.)</simpara>\r
1246 <simpara>If you decide you want the history back, you can always create a new\r
1247 reference pointing to it, for example, a new branch:</simpara>\r
1248 <literallayout>$ git branch recovered-branch 7281251ddd</literallayout>\r
1249 <simpara>Other types of dangling objects (blobs and trees) are also possible, and\r
1250 dangling objects can arise in other situations.</simpara>\r
1251 </section>\r
1252 </section>\r
1253 </section>\r
1254 </section>\r
1255 <section id="Git User Manual_sharing-development">\r
1256 <title>Sharing development with others</title>\r
1257 <section id="Git User Manual_getting-updates-With-git-pull">\r
1258 <title>Getting updates with git pull</title>\r
1259 <simpara>After you clone a repository and commit a few changes of your own, you\r
1260 may wish to check the original repository for updates and merge them\r
1261 into your own work.</simpara>\r
1262 <simpara>We have already seen <link linkend="Git User Manual_Updating-a-repository-With-git-fetch">how to keep remote-tracking branches up to date</link> with <xref linkend="git-fetch(1)" />,\r
1263 and how to merge two branches.  So you can merge in changes from the\r
1264 original repository's master branch with:</simpara>\r
1265 <literallayout>$ git fetch\r
1266 $ git merge origin/master</literallayout>\r
1267 <simpara>However, the <xref linkend="git-pull(1)" /> command provides a way to do this in\r
1268 one step:</simpara>\r
1269 <literallayout>$ git pull origin master</literallayout>\r
1270 <simpara>In fact, if you have <emphasis>master</emphasis> checked out, then this branch has been\r
1271 configured by <emphasis>git clone</emphasis> to get changes from the HEAD branch of the\r
1272 origin repository.  So often you can\r
1273 accomplish the above with just a simple</simpara>\r
1274 <literallayout>$ git pull</literallayout>\r
1275 <simpara>This command will fetch changes from the remote branches to your\r
1276 remote-tracking branches <emphasis>origin/*</emphasis>, and merge the default branch into\r
1277 the current branch.</simpara>\r
1278 <simpara>More generally, a branch that is created from a remote-tracking branch\r
1279 will pull\r
1280 by default from that branch.  See the descriptions of the\r
1281 <emphasis>branch.&lt;name&gt;.remote</emphasis> and <emphasis>branch.&lt;name&gt;.merge</emphasis> options in\r
1282 <xref linkend="git-config(1)" />, and the discussion of the <emphasis>--track</emphasis> option in\r
1283 <xref linkend="git-checkout(1)" />, to learn how to control these defaults.</simpara>\r
1284 <simpara>In addition to saving you keystrokes, <emphasis>git pull</emphasis> also helps you by\r
1285 producing a default commit message documenting the branch and\r
1286 repository that you pulled from.</simpara>\r
1287 <simpara>(But note that no such commit will be created in the case of a\r
1288 <link linkend="Git User Manual_fast-forwards">fast-forward</link>; instead, your branch will just be\r
1289 updated to point to the latest commit from the upstream branch.)</simpara>\r
1290 <simpara>The <emphasis>git pull</emphasis> command can also be given <emphasis>.</emphasis> as the "remote" repository,\r
1291 in which case it just merges in a branch from the current repository; so\r
1292 the commands</simpara>\r
1293 <literallayout>$ git pull . branch\r
1294 $ git merge branch</literallayout>\r
1295 <simpara>are roughly equivalent.</simpara>\r
1296 </section>\r
1297 <section id="Git User Manual_submitting-patches">\r
1298 <title>Submitting patches to a project</title>\r
1299 <simpara>If you just have a few changes, the simplest way to submit them may\r
1300 just be to send them as patches in email:</simpara>\r
1301 <simpara>First, use <xref linkend="git-format-patch(1)" />; for example:</simpara>\r
1302 <literallayout>$ git format-patch origin</literallayout>\r
1303 <simpara>will produce a numbered series of files in the current directory, one\r
1304 for each patch in the current branch but not in <emphasis>origin/HEAD</emphasis>.</simpara>\r
1305 <simpara><emphasis>git format-patch</emphasis> can include an initial "cover letter". You can insert\r
1306 commentary on individual patches after the three dash line which\r
1307 <emphasis>format-patch</emphasis> places after the commit message but before the patch\r
1308 itself.  If you use <emphasis>git notes</emphasis> to track your cover letter material,\r
1309 <emphasis>git format-patch --notes</emphasis> will include the commit's notes in a similar\r
1310 manner.</simpara>\r
1311 <simpara>You can then import these into your mail client and send them by\r
1312 hand.  However, if you have a lot to send at once, you may prefer to\r
1313 use the <xref linkend="git-send-email(1)" /> script to automate the process.\r
1314 Consult the mailing list for your project first to determine\r
1315 their requirements for submitting patches.</simpara>\r
1316 </section>\r
1317 <section id="Git User Manual_importing-patches">\r
1318 <title>Importing patches to a project</title>\r
1319 <simpara>Git also provides a tool called <xref linkend="git-am(1)" /> (am stands for\r
1320 "apply mailbox"), for importing such an emailed series of patches.\r
1321 Just save all of the patch-containing messages, in order, into a\r
1322 single mailbox file, say <emphasis>patches.mbox</emphasis>, then run</simpara>\r
1323 <literallayout>$ git am -3 patches.mbox</literallayout>\r
1324 <simpara>Git will apply each patch in order; if any conflicts are found, it\r
1325 will stop, and you can fix the conflicts as described in\r
1326 "<link linkend="Git User Manual_resolving-a-merge">Resolving a merge</link>".  (The <emphasis>-3</emphasis> option tells\r
1327 Git to perform a merge; if you would prefer it just to abort and\r
1328 leave your tree and index untouched, you may omit that option.)</simpara>\r
1329 <simpara>Once the index is updated with the results of the conflict\r
1330 resolution, instead of creating a new commit, just run</simpara>\r
1331 <literallayout>$ git am --continue</literallayout>\r
1332 <simpara>and Git will create the commit for you and continue applying the\r
1333 remaining patches from the mailbox.</simpara>\r
1334 <simpara>The final result will be a series of commits, one for each patch in\r
1335 the original mailbox, with authorship and commit log message each\r
1336 taken from the message containing each patch.</simpara>\r
1337 </section>\r
1338 <section id="Git User Manual_public-repositories">\r
1339 <title>Public Git repositories</title>\r
1340 <simpara>Another way to submit changes to a project is to tell the maintainer\r
1341 of that project to pull the changes from your repository using\r
1342 <xref linkend="git-pull(1)" />.  In the section "<link linkend="Git User Manual_getting-updates-With-git-pull">Getting updates with <emphasis>git pull</emphasis></link>" we described this as a way to get\r
1343 updates from the "main" repository, but it works just as well in the\r
1344 other direction.</simpara>\r
1345 <simpara>If you and the maintainer both have accounts on the same machine, then\r
1346 you can just pull changes from each other's repositories directly;\r
1347 commands that accept repository URLs as arguments will also accept a\r
1348 local directory name:</simpara>\r
1349 <literallayout>$ git clone /path/to/repository\r
1350 $ git pull /path/to/other/repository</literallayout>\r
1351 <simpara>or an ssh URL:</simpara>\r
1352 <literallayout>$ git clone ssh://yourhost/~you/repository</literallayout>\r
1353 <simpara>For projects with few developers, or for synchronizing a few private\r
1354 repositories, this may be all you need.</simpara>\r
1355 <simpara>However, the more common way to do this is to maintain a separate public\r
1356 repository (usually on a different host) for others to pull changes\r
1357 from.  This is usually more convenient, and allows you to cleanly\r
1358 separate private work in progress from publicly visible work.</simpara>\r
1359 <simpara>You will continue to do your day-to-day work in your personal\r
1360 repository, but periodically "push" changes from your personal\r
1361 repository into your public repository, allowing other developers to\r
1362 pull from that repository.  So the flow of changes, in a situation\r
1363 where there is one other developer with a public repository, looks\r
1364 like this:</simpara>\r
1365 <literallayout class="monospaced">                      you push\r
1366 your personal repo ------------------&gt; your public repo\r
1367       ^                                     |\r
1368       |                                     |\r
1369       | you pull                            | they pull\r
1370       |                                     |\r
1371       |                                     |\r
1372       |               they push             V\r
1373 their public repo &lt;------------------- their repo</literallayout>\r
1374 <simpara>We explain how to do this in the following sections.</simpara>\r
1375 <section id="Git User Manual_setting-up-a-public-repository">\r
1376 <title>Setting up a public repository</title>\r
1377 <simpara>Assume your personal repository is in the directory <emphasis>~/proj</emphasis>.  We\r
1378 first create a new clone of the repository and tell <emphasis>git daemon</emphasis> that it\r
1379 is meant to be public:</simpara>\r
1380 <literallayout>$ git clone --bare ~/proj proj.git\r
1381 $ touch proj.git/git-daemon-export-ok</literallayout>\r
1382 <simpara>The resulting directory proj.git contains a "bare" git repository--it is\r
1383 just the contents of the <emphasis>.git</emphasis> directory, without any files checked out\r
1384 around it.</simpara>\r
1385 <simpara>Next, copy <emphasis>proj.git</emphasis> to the server where you plan to host the\r
1386 public repository.  You can use scp, rsync, or whatever is most\r
1387 convenient.</simpara>\r
1388 </section>\r
1389 <section id="Git User Manual_exporting-via-git">\r
1390 <title>Exporting a Git repository via the Git protocol</title>\r
1391 <simpara>This is the preferred method.</simpara>\r
1392 <simpara>If someone else administers the server, they should tell you what\r
1393 directory to put the repository in, and what <emphasis>git://</emphasis> URL it will\r
1394 appear at.  You can then skip to the section\r
1395 "<link linkend="Git User Manual_pushing-changes-to-a-public-repository">Pushing changes to a public repository</link>", below.</simpara>\r
1396 <simpara>Otherwise, all you need to do is start <xref linkend="git-daemon(1)" />; it will\r
1397 listen on port 9418.  By default, it will allow access to any directory\r
1398 that looks like a Git directory and contains the magic file\r
1399 git-daemon-export-ok.  Passing some directory paths as <emphasis>git daemon</emphasis>\r
1400 arguments will further restrict the exports to those paths.</simpara>\r
1401 <simpara>You can also run <emphasis>git daemon</emphasis> as an inetd service; see the\r
1402 <xref linkend="git-daemon(1)" /> man page for details.  (See especially the\r
1403 examples section.)</simpara>\r
1404 </section>\r
1405 <section id="Git User Manual_exporting-via-http">\r
1406 <title>Exporting a git repository via HTTP</title>\r
1407 <simpara>The Git protocol gives better performance and reliability, but on a\r
1408 host with a web server set up, HTTP exports may be simpler to set up.</simpara>\r
1409 <simpara>All you need to do is place the newly created bare Git repository in\r
1410 a directory that is exported by the web server, and make some\r
1411 adjustments to give web clients some extra information they need:</simpara>\r
1412 <literallayout>$ mv proj.git /home/you/public_html/proj.git\r
1413 $ cd proj.git\r
1414 $ git --bare update-server-info\r
1415 $ mv hooks/post-update.sample hooks/post-update</literallayout>\r
1416 <simpara>(For an explanation of the last two lines, see\r
1417 <xref linkend="git-update-server-info(1)" /> and <xref linkend="githooks(5)" />.)</simpara>\r
1418 <simpara>Advertise the URL of <emphasis>proj.git</emphasis>.  Anybody else should then be able to\r
1419 clone or pull from that URL, for example with a command line like:</simpara>\r
1420 <literallayout>$ git clone http://yourserver.com/~you/proj.git</literallayout>\r
1421 <simpara>(See also\r
1422 link:howto/setup-git-server-over-http.html[setup-git-server-over-http]\r
1423 for a slightly more sophisticated setup using WebDAV which also\r
1424 allows pushing over HTTP.)</simpara>\r
1425 </section>\r
1426 <section id="Git User Manual_pushing-changes-to-a-public-repository">\r
1427 <title>Pushing changes to a public repository</title>\r
1428 <simpara>Note that the two techniques outlined above (exporting via\r
1429 <link linkend="Git User Manual_exporting-via-http">http</link> or <link linkend="Git User Manual_exporting-via-git">git</link>) allow other\r
1430 maintainers to fetch your latest changes, but they do not allow write\r
1431 access, which you will need to update the public repository with the\r
1432 latest changes created in your private repository.</simpara>\r
1433 <simpara>The simplest way to do this is using <xref linkend="git-push(1)" /> and ssh; to\r
1434 update the remote branch named <emphasis>master</emphasis> with the latest state of your\r
1435 branch named <emphasis>master</emphasis>, run</simpara>\r
1436 <literallayout>$ git push ssh://yourserver.com/~you/proj.git master:master</literallayout>\r
1437 <simpara>or just</simpara>\r
1438 <literallayout>$ git push ssh://yourserver.com/~you/proj.git master</literallayout>\r
1439 <simpara>As with <emphasis>git fetch</emphasis>, <emphasis>git push</emphasis> will complain if this does not result in a\r
1440 <link linkend="Git User Manual_fast-forwards">fast-forward</link>; see the following section for details on\r
1441 handling this case.</simpara>\r
1442 <simpara>Note that the target of a <emphasis>push</emphasis> is normally a\r
1443 <link linkend="Git User Manual_def_bare_repository">bare</link> repository.  You can also push to a\r
1444 repository that has a checked-out working tree, but a push to update the\r
1445 currently checked-out branch is denied by default to prevent confusion.\r
1446 See the description of the receive.denyCurrentBranch option\r
1447 in <xref linkend="git-config(1)" /> for details.</simpara>\r
1448 <simpara>As with <emphasis>git fetch</emphasis>, you may also set up configuration options to\r
1449 save typing; so, for example:</simpara>\r
1450 <literallayout>$ git remote add public-repo ssh://yourserver.com/~you/proj.git</literallayout>\r
1451 <simpara>adds the following to <emphasis>.git/config</emphasis>:</simpara>\r
1452 <literallayout>[remote "public-repo"]\r
1453         url = yourserver.com:proj.git\r
1454         fetch = +refs/heads/*:refs/remotes/example/*</literallayout>\r
1455 <simpara>which lets you do the same push with just</simpara>\r
1456 <literallayout>$ git push public-repo master</literallayout>\r
1457 <simpara>See the explanations of the <emphasis>remote.&lt;name&gt;.url</emphasis>,\r
1458 <emphasis>branch.&lt;name&gt;.remote</emphasis>, and <emphasis>remote.&lt;name&gt;.push</emphasis> options in\r
1459 <xref linkend="git-config(1)" /> for details.</simpara>\r
1460 </section>\r
1461 <section id="Git User Manual_forcing-push">\r
1462 <title>What to do when a push fails</title>\r
1463 <simpara>If a push would not result in a <link linkend="Git User Manual_fast-forwards">fast-forward</link> of the\r
1464 remote branch, then it will fail with an error like:</simpara>\r
1465 <literallayout>error: remote 'refs/heads/master' is not an ancestor of\r
1466  local  'refs/heads/master'.\r
1467  Maybe you are not up-to-date and need to pull first?\r
1468 error: failed to push to 'ssh://yourserver.com/~you/proj.git'</literallayout>\r
1469 <simpara>This can happen, for example, if you:</simpara>\r
1470 <itemizedlist>\r
1471 <listitem>\r
1472 <simpara>\r
1473 use <emphasis>git reset --hard</emphasis> to remove already-published commits, or\r
1474 </simpara>\r
1475 </listitem>\r
1476 <listitem>\r
1477 <simpara>\r
1478 use <emphasis>git commit --amend</emphasis> to replace already-published commits\r
1479           (as in <xref linkend="Git User Manual_fixing-a-mistake-by-rewriting-history"/>), or\r
1480 </simpara>\r
1481 </listitem>\r
1482 <listitem>\r
1483 <simpara>\r
1484 use <emphasis>git rebase</emphasis> to rebase any already-published commits (as\r
1485           in <xref linkend="Git User Manual_using-git-rebase"/>).\r
1486 </simpara>\r
1487 </listitem>\r
1488 </itemizedlist>\r
1489 <simpara>You may force <emphasis>git push</emphasis> to perform the update anyway by preceding the\r
1490 branch name with a plus sign:</simpara>\r
1491 <literallayout>$ git push ssh://yourserver.com/~you/proj.git +master</literallayout>\r
1492 <simpara>Note the addition of the <emphasis>+</emphasis> sign.  Alternatively, you can use the\r
1493 <emphasis>-f</emphasis> flag to force the remote update, as in:</simpara>\r
1494 <literallayout>$ git push -f ssh://yourserver.com/~you/proj.git master</literallayout>\r
1495 <simpara>Normally whenever a branch head in a public repository is modified, it\r
1496 is modified to point to a descendant of the commit that it pointed to\r
1497 before.  By forcing a push in this situation, you break that convention.\r
1498 (See <xref linkend="Git User Manual_problems-With-rewriting-history"/>.)</simpara>\r
1499 <simpara>Nevertheless, this is a common practice for people that need a simple\r
1500 way to publish a work-in-progress patch series, and it is an acceptable\r
1501 compromise as long as you warn other developers that this is how you\r
1502 intend to manage the branch.</simpara>\r
1503 <simpara>It's also possible for a push to fail in this way when other people have\r
1504 the right to push to the same repository.  In that case, the correct\r
1505 solution is to retry the push after first updating your work: either by a\r
1506 pull, or by a fetch followed by a rebase; see the\r
1507 <link linkend="Git User Manual_setting-up-a-shared-repository">next section</link> and\r
1508 <xref linkend="gitcvs-migration(7)" /> for more.</simpara>\r
1509 </section>\r
1510 <section id="Git User Manual_setting-up-a-shared-repository">\r
1511 <title>Setting up a shared repository</title>\r
1512 <simpara>Another way to collaborate is by using a model similar to that\r
1513 commonly used in CVS, where several developers with special rights\r
1514 all push to and pull from a single shared repository.  See\r
1515 <xref linkend="gitcvs-migration(7)" /> for instructions on how to\r
1516 set this up.</simpara>\r
1517 <simpara>However, while there is nothing wrong with Git's support for shared\r
1518 repositories, this mode of operation is not generally recommended,\r
1519 simply because the mode of collaboration that Git supports--by\r
1520 exchanging patches and pulling from public repositories--has so many\r
1521 advantages over the central shared repository:</simpara>\r
1522 <itemizedlist>\r
1523 <listitem>\r
1524 <simpara>\r
1525 Git's ability to quickly import and merge patches allows a\r
1526           single maintainer to process incoming changes even at very\r
1527           high rates.  And when that becomes too much, <emphasis>git pull</emphasis> provides\r
1528           an easy way for that maintainer to delegate this job to other\r
1529           maintainers while still allowing optional review of incoming\r
1530           changes.\r
1531 </simpara>\r
1532 </listitem>\r
1533 <listitem>\r
1534 <simpara>\r
1535 Since every developer's repository has the same complete copy\r
1536           of the project history, no repository is special, and it is\r
1537           trivial for another developer to take over maintenance of a\r
1538           project, either by mutual agreement, or because a maintainer\r
1539           becomes unresponsive or difficult to work with.\r
1540 </simpara>\r
1541 </listitem>\r
1542 <listitem>\r
1543 <simpara>\r
1544 The lack of a central group of "committers" means there is\r
1545           less need for formal decisions about who is "in" and who is\r
1546           "out".\r
1547 </simpara>\r
1548 </listitem>\r
1549 </itemizedlist>\r
1550 </section>\r
1551 <section id="Git User Manual_setting-up-gitweb">\r
1552 <title>Allowing web browsing of a repository</title>\r
1553 <simpara>The gitweb cgi script provides users an easy way to browse your\r
1554 project's revisions, file contents and logs without having to install\r
1555 Git. Features like RSS/Atom feeds and blame/annotation details may\r
1556 optionally be enabled.</simpara>\r
1557 <simpara>The <xref linkend="git-instaweb(1)" /> command provides a simple way to start\r
1558 browsing the repository using gitweb. The default server when using\r
1559 instaweb is lighttpd.</simpara>\r
1560 <simpara>See the file gitweb/INSTALL in the Git source tree and\r
1561 <xref linkend="gitweb(1)" /> for instructions on details setting up a permanent\r
1562 installation with a CGI or Perl capable server.</simpara>\r
1563 </section>\r
1564 </section>\r
1565 <section id="Git User Manual_how-to-get-a-git-repository-with-minimal-history">\r
1566 <title>How to get a Git repository with minimal history</title>\r
1567 <simpara>A <link linkend="Git User Manual_def_shallow_clone">shallow clone</link>, with its truncated\r
1568 history, is useful when one is interested only in recent history\r
1569 of a project and getting full history from the upstream is\r
1570 expensive.</simpara>\r
1571 <simpara>A <link linkend="Git User Manual_def_shallow_clone">shallow clone</link> is created by specifying\r
1572 the <xref linkend="git-clone(1)" /> <emphasis>--depth</emphasis> switch. The depth can later be\r
1573 changed with the <xref linkend="git-fetch(1)" /> <emphasis>--depth</emphasis> switch, or full\r
1574 history restored with <emphasis>--unshallow</emphasis>.</simpara>\r
1575 <simpara>Merging inside a <link linkend="Git User Manual_def_shallow_clone">shallow clone</link> will work as long\r
1576 as a merge base is in the recent history.\r
1577 Otherwise, it will be like merging unrelated histories and may\r
1578 have to result in huge conflicts.  This limitation may make such\r
1579 a repository unsuitable to be used in merge based workflows.</simpara>\r
1580 </section>\r
1581 <section id="Git User Manual_sharing-development-examples">\r
1582 <title>Examples</title>\r
1583 <section id="Git User Manual_maintaining-topic-branches">\r
1584 <title>Maintaining topic branches for a Linux subsystem maintainer</title>\r
1585 <simpara>This describes how Tony Luck uses Git in his role as maintainer of the\r
1586 IA64 architecture for the Linux kernel.</simpara>\r
1587 <simpara>He uses two public branches:</simpara>\r
1588 <itemizedlist>\r
1589 <listitem>\r
1590 <simpara>\r
1591 A "test" tree into which patches are initially placed so that they\r
1592    can get some exposure when integrated with other ongoing development.\r
1593    This tree is available to Andrew for pulling into -mm whenever he\r
1594    wants.\r
1595 </simpara>\r
1596 </listitem>\r
1597 <listitem>\r
1598 <simpara>\r
1599 A "release" tree into which tested patches are moved for final sanity\r
1600    checking, and as a vehicle to send them upstream to Linus (by sending\r
1601    him a "please pull" request.)\r
1602 </simpara>\r
1603 </listitem>\r
1604 </itemizedlist>\r
1605 <simpara>He also uses a set of temporary branches ("topic branches"), each\r
1606 containing a logical grouping of patches.</simpara>\r
1607 <simpara>To set this up, first create your work tree by cloning Linus's public\r
1608 tree:</simpara>\r
1609 <literallayout>$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git work\r
1610 $ cd work</literallayout>\r
1611 <simpara>Linus's tree will be stored in the remote-tracking branch named origin/master,\r
1612 and can be updated using <xref linkend="git-fetch(1)" />; you can track other\r
1613 public trees using <xref linkend="git-remote(1)" /> to set up a "remote" and\r
1614 <xref linkend="git-fetch(1)" /> to keep them up-to-date; see\r
1615 <xref linkend="Git User Manual_repositories-and-branches"/>.</simpara>\r
1616 <simpara>Now create the branches in which you are going to work; these start out\r
1617 at the current tip of origin/master branch, and should be set up (using\r
1618 the <emphasis>--track</emphasis> option to <xref linkend="git-branch(1)" />) to merge changes in from\r
1619 Linus by default.</simpara>\r
1620 <literallayout>$ git branch --track test origin/master\r
1621 $ git branch --track release origin/master</literallayout>\r
1622 <simpara>These can be easily kept up to date using <xref linkend="git-pull(1)" />.</simpara>\r
1623 <literallayout>$ git checkout test &amp;&amp; git pull\r
1624 $ git checkout release &amp;&amp; git pull</literallayout>\r
1625 <simpara>Important note!  If you have any local changes in these branches, then\r
1626 this merge will create a commit object in the history (with no local\r
1627 changes Git will simply do a "fast-forward" merge).  Many people dislike\r
1628 the "noise" that this creates in the Linux history, so you should avoid\r
1629 doing this capriciously in the <emphasis>release</emphasis> branch, as these noisy commits\r
1630 will become part of the permanent history when you ask Linus to pull\r
1631 from the release branch.</simpara>\r
1632 <simpara>A few configuration variables (see <xref linkend="git-config(1)" />) can\r
1633 make it easy to push both branches to your public tree.  (See\r
1634 <xref linkend="Git User Manual_setting-up-a-public-repository"/>.)</simpara>\r
1635 <literallayout>$ cat &gt;&gt; .git/config &lt;&lt;EOF\r
1636 [remote "mytree"]\r
1637         url =  master.kernel.org:/pub/scm/linux/kernel/git/aegl/linux.git\r
1638         push = release\r
1639         push = test\r
1640 EOF</literallayout>\r
1641 <simpara>Then you can push both the test and release trees using\r
1642 <xref linkend="git-push(1)" />:</simpara>\r
1643 <literallayout>$ git push mytree</literallayout>\r
1644 <simpara>or push just one of the test and release branches using:</simpara>\r
1645 <literallayout>$ git push mytree test</literallayout>\r
1646 <simpara>or</simpara>\r
1647 <literallayout>$ git push mytree release</literallayout>\r
1648 <simpara>Now to apply some patches from the community.  Think of a short\r
1649 snappy name for a branch to hold this patch (or related group of\r
1650 patches), and create a new branch from a recent stable tag of\r
1651 Linus's branch. Picking a stable base for your branch will:\r
1652 1) help you: by avoiding inclusion of unrelated and perhaps lightly\r
1653 tested changes\r
1654 2) help future bug hunters that use <emphasis>git bisect</emphasis> to find problems</simpara>\r
1655 <literallayout>$ git checkout -b speed-up-spinlocks v2.6.35</literallayout>\r
1656 <simpara>Now you apply the patch(es), run some tests, and commit the change(s).  If\r
1657 the patch is a multi-part series, then you should apply each as a separate\r
1658 commit to this branch.</simpara>\r
1659 <literallayout>$ ... patch ... test  ... commit [ ... patch ... test ... commit ]*</literallayout>\r
1660 <simpara>When you are happy with the state of this change, you can merge it into the\r
1661 "test" branch in preparation to make it public:</simpara>\r
1662 <literallayout>$ git checkout test &amp;&amp; git merge speed-up-spinlocks</literallayout>\r
1663 <simpara>It is unlikely that you would have any conflicts here &#8230; but you might if you\r
1664 spent a while on this step and had also pulled new versions from upstream.</simpara>\r
1665 <simpara>Sometime later when enough time has passed and testing done, you can pull the\r
1666 same branch into the <emphasis>release</emphasis> tree ready to go upstream.  This is where you\r
1667 see the value of keeping each patch (or patch series) in its own branch.  It\r
1668 means that the patches can be moved into the <emphasis>release</emphasis> tree in any order.</simpara>\r
1669 <literallayout>$ git checkout release &amp;&amp; git merge speed-up-spinlocks</literallayout>\r
1670 <simpara>After a while, you will have a number of branches, and despite the\r
1671 well chosen names you picked for each of them, you may forget what\r
1672 they are for, or what status they are in.  To get a reminder of what\r
1673 changes are in a specific branch, use:</simpara>\r
1674 <literallayout>$ git log linux..branchname | git shortlog</literallayout>\r
1675 <simpara>To see whether it has already been merged into the test or release branches,\r
1676 use:</simpara>\r
1677 <literallayout>$ git log test..branchname</literallayout>\r
1678 <simpara>or</simpara>\r
1679 <literallayout>$ git log release..branchname</literallayout>\r
1680 <simpara>(If this branch has not yet been merged, you will see some log entries.\r
1681 If it has been merged, then there will be no output.)</simpara>\r
1682 <simpara>Once a patch completes the great cycle (moving from test to release,\r
1683 then pulled by Linus, and finally coming back into your local\r
1684 <emphasis>origin/master</emphasis> branch), the branch for this change is no longer needed.\r
1685 You detect this when the output from:</simpara>\r
1686 <literallayout>$ git log origin..branchname</literallayout>\r
1687 <simpara>is empty.  At this point the branch can be deleted:</simpara>\r
1688 <literallayout>$ git branch -d branchname</literallayout>\r
1689 <simpara>Some changes are so trivial that it is not necessary to create a separate\r
1690 branch and then merge into each of the test and release branches.  For\r
1691 these changes, just apply directly to the <emphasis>release</emphasis> branch, and then\r
1692 merge that into the <emphasis>test</emphasis> branch.</simpara>\r
1693 <simpara>After pushing your work to <emphasis>mytree</emphasis>, you can use\r
1694 <xref linkend="git-request-pull(1)" /> to prepare a "please pull" request message\r
1695 to send to Linus:</simpara>\r
1696 <literallayout>$ git push mytree\r
1697 $ git request-pull origin mytree release</literallayout>\r
1698 <simpara>Here are some of the scripts that simplify all this even further.</simpara>\r
1699 <literallayout>==== update script ====\r
1700 # Update a branch in my Git tree.  If the branch to be updated\r
1701 # is origin, then pull from kernel.org.  Otherwise merge\r
1702 # origin/master branch into test|release branch\r
1704 case "$1" in\r
1705 test|release)\r
1706         git checkout $1 &amp;&amp; git pull . origin\r
1707         ;;\r
1708 origin)\r
1709         before=$(git rev-parse refs/remotes/origin/master)\r
1710         git fetch origin\r
1711         after=$(git rev-parse refs/remotes/origin/master)\r
1712         if [ $before != $after ]\r
1713         then\r
1714                 git log $before..$after | git shortlog\r
1715         fi\r
1716         ;;\r
1717 *)\r
1718         echo "usage: $0 origin|test|release" 1&gt;&amp;2\r
1719         exit 1\r
1720         ;;\r
1721 esac</literallayout>\r
1722 <literallayout>==== merge script ====\r
1723 # Merge a branch into either the test or release branch\r
1725 pname=$0\r
1727 usage()\r
1729         echo "usage: $pname branch test|release" 1&gt;&amp;2\r
1730         exit 1\r
1733 git show-ref -q --verify -- refs/heads/"$1" || {\r
1734         echo "Can't see branch &lt;$1&gt;" 1&gt;&amp;2\r
1735         usage\r
1738 case "$2" in\r
1739 test|release)\r
1740         if [ $(git log $2..$1 | wc -c) -eq 0 ]\r
1741         then\r
1742                 echo $1 already merged into $2 1&gt;&amp;2\r
1743                 exit 1\r
1744         fi\r
1745         git checkout $2 &amp;&amp; git pull . $1\r
1746         ;;\r
1747 *)\r
1748         usage\r
1749         ;;\r
1750 esac</literallayout>\r
1751 <literallayout>==== status script ====\r
1752 # report on status of my ia64 Git tree\r
1754 gb=$(tput setab 2)\r
1755 rb=$(tput setab 1)\r
1756 restore=$(tput setab 9)\r
1758 if [ `git rev-list test..release | wc -c` -gt 0 ]\r
1759 then\r
1760         echo $rb Warning: commits in release that are not in test $restore\r
1761         git log test..release\r
1762 fi\r
1764 for branch in `git show-ref --heads | sed 's|^.*/||'`\r
1765 do\r
1766         if [ $branch = test -o $branch = release ]\r
1767         then\r
1768                 continue\r
1769         fi\r
1771         echo -n $gb ======= $branch ====== $restore " "\r
1772         status=\r
1773         for ref in test release origin/master\r
1774         do\r
1775                 if [ `git rev-list $ref..$branch | wc -c` -gt 0 ]\r
1776                 then\r
1777                         status=$status${ref:0:1}\r
1778                 fi\r
1779         done\r
1780         case $status in\r
1781         trl)\r
1782                 echo $rb Need to pull into test $restore\r
1783                 ;;\r
1784         rl)\r
1785                 echo "In test"\r
1786                 ;;\r
1787         l)\r
1788                 echo "Waiting for linus"\r
1789                 ;;\r
1790         "")\r
1791                 echo $rb All done $restore\r
1792                 ;;\r
1793         *)\r
1794                 echo $rb "&lt;$status&gt;" $restore\r
1795                 ;;\r
1796         esac\r
1797         git log origin/master..$branch | git shortlog\r
1798 done</literallayout>\r
1799 </section>\r
1800 </section>\r
1801 </section>\r
1802 <section id="Git User Manual_cleaning-up-history">\r
1803 <title>Rewriting history and maintaining patch series</title>\r
1804 <simpara>Normally commits are only added to a project, never taken away or\r
1805 replaced.  Git is designed with this assumption, and violating it will\r
1806 cause Git's merge machinery (for example) to do the wrong thing.</simpara>\r
1807 <simpara>However, there is a situation in which it can be useful to violate this\r
1808 assumption.</simpara>\r
1809 <section id="Git User Manual_patch-series">\r
1810 <title>Creating the perfect patch series</title>\r
1811 <simpara>Suppose you are a contributor to a large project, and you want to add a\r
1812 complicated feature, and to present it to the other developers in a way\r
1813 that makes it easy for them to read your changes, verify that they are\r
1814 correct, and understand why you made each change.</simpara>\r
1815 <simpara>If you present all of your changes as a single patch (or commit), they\r
1816 may find that it is too much to digest all at once.</simpara>\r
1817 <simpara>If you present them with the entire history of your work, complete with\r
1818 mistakes, corrections, and dead ends, they may be overwhelmed.</simpara>\r
1819 <simpara>So the ideal is usually to produce a series of patches such that:</simpara>\r
1820 <orderedlist numeration="arabic">\r
1821 <listitem>\r
1822 <simpara>\r
1823 Each patch can be applied in order.\r
1824 </simpara>\r
1825 </listitem>\r
1826 <listitem>\r
1827 <simpara>\r
1828 Each patch includes a single logical change, together with a\r
1829            message explaining the change.\r
1830 </simpara>\r
1831 </listitem>\r
1832 <listitem>\r
1833 <simpara>\r
1834 No patch introduces a regression: after applying any initial\r
1835            part of the series, the resulting project still compiles and\r
1836            works, and has no bugs that it didn't have before.\r
1837 </simpara>\r
1838 </listitem>\r
1839 <listitem>\r
1840 <simpara>\r
1841 The complete series produces the same end result as your own\r
1842            (probably much messier!) development process did.\r
1843 </simpara>\r
1844 </listitem>\r
1845 </orderedlist>\r
1846 <simpara>We will introduce some tools that can help you do this, explain how to\r
1847 use them, and then explain some of the problems that can arise because\r
1848 you are rewriting history.</simpara>\r
1849 </section>\r
1850 <section id="Git User Manual_using-git-rebase">\r
1851 <title>Keeping a patch series up to date using git rebase</title>\r
1852 <simpara>Suppose that you create a branch <emphasis>mywork</emphasis> on a remote-tracking branch\r
1853 <emphasis>origin</emphasis>, and create some commits on top of it:</simpara>\r
1854 <literallayout>$ git checkout -b mywork origin\r
1855 $ vi file.txt\r
1856 $ git commit\r
1857 $ vi otherfile.txt\r
1858 $ git commit\r
1859 ...</literallayout>\r
1860 <simpara>You have performed no merges into mywork, so it is just a simple linear\r
1861 sequence of patches on top of <emphasis>origin</emphasis>:</simpara>\r
1862 <literallayout class="monospaced"> o--o--O &lt;-- origin\r
1863         \\r
1864          a--b--c &lt;-- mywork</literallayout>\r
1865 <simpara>Some more interesting work has been done in the upstream project, and\r
1866 <emphasis>origin</emphasis> has advanced:</simpara>\r
1867 <literallayout class="monospaced"> o--o--O--o--o--o &lt;-- origin\r
1868         \\r
1869          a--b--c &lt;-- mywork</literallayout>\r
1870 <simpara>At this point, you could use <emphasis>pull</emphasis> to merge your changes back in;\r
1871 the result would create a new merge commit, like this:</simpara>\r
1872 <literallayout class="monospaced"> o--o--O--o--o--o &lt;-- origin\r
1873         \        \\r
1874          a--b--c--m &lt;-- mywork</literallayout>\r
1875 <simpara>However, if you prefer to keep the history in mywork a simple series of\r
1876 commits without any merges, you may instead choose to use\r
1877 <xref linkend="git-rebase(1)" />:</simpara>\r
1878 <literallayout>$ git checkout mywork\r
1879 $ git rebase origin</literallayout>\r
1880 <simpara>This will remove each of your commits from mywork, temporarily saving\r
1881 them as patches (in a directory named <emphasis>.git/rebase-apply</emphasis>), update mywork to\r
1882 point at the latest version of origin, then apply each of the saved\r
1883 patches to the new mywork.  The result will look like:</simpara>\r
1884 <literallayout class="monospaced"> o--o--O--o--o--o &lt;-- origin\r
1885                  \\r
1886                   a'--b'--c' &lt;-- mywork</literallayout>\r
1887 <simpara>In the process, it may discover conflicts.  In that case it will stop\r
1888 and allow you to fix the conflicts; after fixing conflicts, use <emphasis>git add</emphasis>\r
1889 to update the index with those contents, and then, instead of\r
1890 running <emphasis>git commit</emphasis>, just run</simpara>\r
1891 <literallayout>$ git rebase --continue</literallayout>\r
1892 <simpara>and Git will continue applying the rest of the patches.</simpara>\r
1893 <simpara>At any point you may use the <emphasis>--abort</emphasis> option to abort this process and\r
1894 return mywork to the state it had before you started the rebase:</simpara>\r
1895 <literallayout>$ git rebase --abort</literallayout>\r
1896 <simpara>If you need to reorder or edit a number of commits in a branch, it may\r
1897 be easier to use <emphasis>git rebase -i</emphasis>, which allows you to reorder and\r
1898 squash commits, as well as marking them for individual editing during\r
1899 the rebase.  See <xref linkend="Git User Manual_interactive-rebase"/> for details, and\r
1900 <xref linkend="Git User Manual_reordering-patch-series"/> for alternatives.</simpara>\r
1901 </section>\r
1902 <section id="Git User Manual_rewriting-one-commit">\r
1903 <title>Rewriting a single commit</title>\r
1904 <simpara>We saw in <xref linkend="Git User Manual_fixing-a-mistake-by-rewriting-history"/> that you can replace the\r
1905 most recent commit using</simpara>\r
1906 <literallayout>$ git commit --amend</literallayout>\r
1907 <simpara>which will replace the old commit by a new commit incorporating your\r
1908 changes, giving you a chance to edit the old commit message first.\r
1909 This is useful for fixing typos in your last commit, or for adjusting\r
1910 the patch contents of a poorly staged commit.</simpara>\r
1911 <simpara>If you need to amend commits from deeper in your history, you can\r
1912 use <link linkend="Git User Manual_interactive-rebase">interactive rebase's <emphasis>edit</emphasis> instruction</link>.</simpara>\r
1913 </section>\r
1914 <section id="Git User Manual_reordering-patch-series">\r
1915 <title>Reordering or selecting from a patch series</title>\r
1916 <simpara>Sometimes you want to edit a commit deeper in your history.  One\r
1917 approach is to use <emphasis>git format-patch</emphasis> to create a series of patches\r
1918 and then reset the state to before the patches:</simpara>\r
1919 <literallayout>$ git format-patch origin\r
1920 $ git reset --hard origin</literallayout>\r
1921 <simpara>Then modify, reorder, or eliminate patches as needed before applying\r
1922 them again with <xref linkend="git-am(1)" />:</simpara>\r
1923 <literallayout>$ git am *.patch</literallayout>\r
1924 </section>\r
1925 <section id="Git User Manual_interactive-rebase">\r
1926 <title>Using interactive rebases</title>\r
1927 <simpara>You can also edit a patch series with an interactive rebase.  This is\r
1928 the same as <link linkend="Git User Manual_reordering-patch-series">reordering a patch series using <emphasis>format-patch</emphasis></link>, so use whichever interface you like best.</simpara>\r
1929 <simpara>Rebase your current HEAD on the last commit you want to retain as-is.\r
1930 For example, if you want to reorder the last 5 commits, use:</simpara>\r
1931 <literallayout>$ git rebase -i HEAD~5</literallayout>\r
1932 <simpara>This will open your editor with a list of steps to be taken to perform\r
1933 your rebase.</simpara>\r
1934 <literallayout>pick deadbee The oneline of this commit\r
1935 pick fa1afe1 The oneline of the next commit\r
1936 ...\r
1938 # Rebase c0ffeee..deadbee onto c0ffeee\r
1940 # Commands:\r
1941 #  p, pick = use commit\r
1942 #  r, reword = use commit, but edit the commit message\r
1943 #  e, edit = use commit, but stop for amending\r
1944 #  s, squash = use commit, but meld into previous commit\r
1945 #  f, fixup = like "squash", but discard this commit's log message\r
1946 #  x, exec = run command (the rest of the line) using shell\r
1948 # These lines can be re-ordered; they are executed from top to bottom.\r
1950 # If you remove a line here THAT COMMIT WILL BE LOST.\r
1952 # However, if you remove everything, the rebase will be aborted.\r
1954 # Note that empty commits are commented out</literallayout>\r
1955 <simpara>As explained in the comments, you can reorder commits, squash them\r
1956 together, edit commit messages, etc. by editing the list.  Once you\r
1957 are satisfied, save the list and close your editor, and the rebase\r
1958 will begin.</simpara>\r
1959 <simpara>The rebase will stop where <emphasis>pick</emphasis> has been replaced with <emphasis>edit</emphasis> or\r
1960 when a step in the list fails to mechanically resolve conflicts and\r
1961 needs your help.  When you are done editing and/or resolving conflicts\r
1962 you can continue with <emphasis>git rebase --continue</emphasis>.  If you decide that\r
1963 things are getting too hairy, you can always bail out with <emphasis>git rebase\r
1964 --abort</emphasis>.  Even after the rebase is complete, you can still recover\r
1965 the original branch by using the <link linkend="Git User Manual_reflogs">reflog</link>.</simpara>\r
1966 <simpara>For a more detailed discussion of the procedure and additional tips,\r
1967 see the "INTERACTIVE MODE" section of <xref linkend="git-rebase(1)" />.</simpara>\r
1968 </section>\r
1969 <section id="Git User Manual_patch-series-tools">\r
1970 <title>Other tools</title>\r
1971 <simpara>There are numerous other tools, such as StGit, which exist for the\r
1972 purpose of maintaining a patch series.  These are outside of the scope of\r
1973 this manual.</simpara>\r
1974 </section>\r
1975 <section id="Git User Manual_problems-With-rewriting-history">\r
1976 <title>Problems with rewriting history</title>\r
1977 <simpara>The primary problem with rewriting the history of a branch has to do\r
1978 with merging.  Suppose somebody fetches your branch and merges it into\r
1979 their branch, with a result something like this:</simpara>\r
1980 <literallayout class="monospaced"> o--o--O--o--o--o &lt;-- origin\r
1981         \        \\r
1982          t--t--t--m &lt;-- their branch:</literallayout>\r
1983 <simpara>Then suppose you modify the last three commits:</simpara>\r
1984 <literallayout class="monospaced">         o--o--o &lt;-- new head of origin\r
1985         /\r
1986  o--o--O--o--o--o &lt;-- old head of origin</literallayout>\r
1987 <simpara>If we examined all this history together in one repository, it will\r
1988 look like:</simpara>\r
1989 <literallayout class="monospaced">         o--o--o &lt;-- new head of origin\r
1990         /\r
1991  o--o--O--o--o--o &lt;-- old head of origin\r
1992         \        \\r
1993          t--t--t--m &lt;-- their branch:</literallayout>\r
1994 <simpara>Git has no way of knowing that the new head is an updated version of\r
1995 the old head; it treats this situation exactly the same as it would if\r
1996 two developers had independently done the work on the old and new heads\r
1997 in parallel.  At this point, if someone attempts to merge the new head\r
1998 in to their branch, Git will attempt to merge together the two (old and\r
1999 new) lines of development, instead of trying to replace the old by the\r
2000 new.  The results are likely to be unexpected.</simpara>\r
2001 <simpara>You may still choose to publish branches whose history is rewritten,\r
2002 and it may be useful for others to be able to fetch those branches in\r
2003 order to examine or test them, but they should not attempt to pull such\r
2004 branches into their own work.</simpara>\r
2005 <simpara>For true distributed development that supports proper merging,\r
2006 published branches should never be rewritten.</simpara>\r
2007 </section>\r
2008 <section id="Git User Manual_bisect-merges">\r
2009 <title>Why bisecting merge commits can be harder than bisecting linear history</title>\r
2010 <simpara>The <xref linkend="git-bisect(1)" /> command correctly handles history that\r
2011 includes merge commits.  However, when the commit that it finds is a\r
2012 merge commit, the user may need to work harder than usual to figure out\r
2013 why that commit introduced a problem.</simpara>\r
2014 <simpara>Imagine this history:</simpara>\r
2015 <literallayout class="monospaced">      ---Z---o---X---...---o---A---C---D\r
2016           \                       /\r
2017            o---o---Y---...---o---B</literallayout>\r
2018 <simpara>Suppose that on the upper line of development, the meaning of one\r
2019 of the functions that exists at Z is changed at commit X.  The\r
2020 commits from Z leading to A change both the function's\r
2021 implementation and all calling sites that exist at Z, as well\r
2022 as new calling sites they add, to be consistent.  There is no\r
2023 bug at A.</simpara>\r
2024 <simpara>Suppose that in the meantime on the lower line of development somebody\r
2025 adds a new calling site for that function at commit Y.  The\r
2026 commits from Z leading to B all assume the old semantics of that\r
2027 function and the callers and the callee are consistent with each\r
2028 other.  There is no bug at B, either.</simpara>\r
2029 <simpara>Suppose further that the two development lines merge cleanly at C,\r
2030 so no conflict resolution is required.</simpara>\r
2031 <simpara>Nevertheless, the code at C is broken, because the callers added\r
2032 on the lower line of development have not been converted to the new\r
2033 semantics introduced on the upper line of development.  So if all\r
2034 you know is that D is bad, that Z is good, and that\r
2035 <xref linkend="git-bisect(1)" /> identifies C as the culprit, how will you\r
2036 figure out that the problem is due to this change in semantics?</simpara>\r
2037 <simpara>When the result of a <emphasis>git bisect</emphasis> is a non-merge commit, you should\r
2038 normally be able to discover the problem by examining just that commit.\r
2039 Developers can make this easy by breaking their changes into small\r
2040 self-contained commits.  That won't help in the case above, however,\r
2041 because the problem isn't obvious from examination of any single\r
2042 commit; instead, a global view of the development is required.  To\r
2043 make matters worse, the change in semantics in the problematic\r
2044 function may be just one small part of the changes in the upper\r
2045 line of development.</simpara>\r
2046 <simpara>On the other hand, if instead of merging at C you had rebased the\r
2047 history between Z to B on top of A, you would have gotten this\r
2048 linear history:</simpara>\r
2049 <literallayout class="monospaced">    ---Z---o---X--...---o---A---o---o---Y*--...---o---B*--D*</literallayout>\r
2050 <simpara>Bisecting between Z and D* would hit a single culprit commit Y*,\r
2051 and understanding why Y* was broken would probably be easier.</simpara>\r
2052 <simpara>Partly for this reason, many experienced Git users, even when\r
2053 working on an otherwise merge-heavy project, keep the history\r
2054 linear by rebasing against the latest upstream version before\r
2055 publishing.</simpara>\r
2056 </section>\r
2057 </section>\r
2058 <section id="Git User Manual_advanced-branch-management">\r
2059 <title>Advanced branch management</title>\r
2060 <section id="Git User Manual_fetching-individual-branches">\r
2061 <title>Fetching individual branches</title>\r
2062 <simpara>Instead of using <xref linkend="git-remote(1)" />, you can also choose just\r
2063 to update one branch at a time, and to store it locally under an\r
2064 arbitrary name:</simpara>\r
2065 <literallayout>$ git fetch origin todo:my-todo-work</literallayout>\r
2066 <simpara>The first argument, <emphasis>origin</emphasis>, just tells Git to fetch from the\r
2067 repository you originally cloned from.  The second argument tells Git\r
2068 to fetch the branch named <emphasis>todo</emphasis> from the remote repository, and to\r
2069 store it locally under the name <emphasis>refs/heads/my-todo-work</emphasis>.</simpara>\r
2070 <simpara>You can also fetch branches from other repositories; so</simpara>\r
2071 <literallayout>$ git fetch git://example.com/proj.git master:example-master</literallayout>\r
2072 <simpara>will create a new branch named <emphasis>example-master</emphasis> and store in it the\r
2073 branch named <emphasis>master</emphasis> from the repository at the given URL.  If you\r
2074 already have a branch named example-master, it will attempt to\r
2075 <link linkend="Git User Manual_fast-forwards">fast-forward</link> to the commit given by example.com's\r
2076 master branch.  In more detail:</simpara>\r
2077 </section>\r
2078 <section id="Git User Manual_fetch-fast-forwards">\r
2079 <title>git fetch and fast-forwards</title>\r
2080 <simpara>In the previous example, when updating an existing branch, <emphasis>git fetch</emphasis>\r
2081 checks to make sure that the most recent commit on the remote\r
2082 branch is a descendant of the most recent commit on your copy of the\r
2083 branch before updating your copy of the branch to point at the new\r
2084 commit.  Git calls this process a <link linkend="Git User Manual_fast-forwards">fast-forward</link>.</simpara>\r
2085 <simpara>A fast-forward looks something like this:</simpara>\r
2086 <literallayout class="monospaced"> o--o--o--o &lt;-- old head of the branch\r
2087            \\r
2088             o--o--o &lt;-- new head of the branch</literallayout>\r
2089 <simpara>In some cases it is possible that the new head will <emphasis role="strong">not</emphasis> actually be\r
2090 a descendant of the old head.  For example, the developer may have\r
2091 realized she made a serious mistake, and decided to backtrack,\r
2092 resulting in a situation like:</simpara>\r
2093 <literallayout class="monospaced"> o--o--o--o--a--b &lt;-- old head of the branch\r
2094            \\r
2095             o--o--o &lt;-- new head of the branch</literallayout>\r
2096 <simpara>In this case, <emphasis>git fetch</emphasis> will fail, and print out a warning.</simpara>\r
2097 <simpara>In that case, you can still force Git to update to the new head, as\r
2098 described in the following section.  However, note that in the\r
2099 situation above this may mean losing the commits labeled <emphasis>a</emphasis> and <emphasis>b</emphasis>,\r
2100 unless you've already created a reference of your own pointing to\r
2101 them.</simpara>\r
2102 </section>\r
2103 <section id="Git User Manual_forcing-fetch">\r
2104 <title>Forcing git fetch to do non-fast-forward updates</title>\r
2105 <simpara>If git fetch fails because the new head of a branch is not a\r
2106 descendant of the old head, you may force the update with:</simpara>\r
2107 <literallayout>$ git fetch git://example.com/proj.git +master:refs/remotes/example/master</literallayout>\r
2108 <simpara>Note the addition of the <emphasis>+</emphasis> sign.  Alternatively, you can use the <emphasis>-f</emphasis>\r
2109 flag to force updates of all the fetched branches, as in:</simpara>\r
2110 <literallayout>$ git fetch -f origin</literallayout>\r
2111 <simpara>Be aware that commits that the old version of example/master pointed at\r
2112 may be lost, as we saw in the previous section.</simpara>\r
2113 </section>\r
2114 <section id="Git User Manual_remote-branch-configuration">\r
2115 <title>Configuring remote-tracking branches</title>\r
2116 <simpara>We saw above that <emphasis>origin</emphasis> is just a shortcut to refer to the\r
2117 repository that you originally cloned from.  This information is\r
2118 stored in Git configuration variables, which you can see using\r
2119 <xref linkend="git-config(1)" />:</simpara>\r
2120 <literallayout>$ git config -l\r
2121 core.repositoryformatversion=0\r
2122 core.filemode=true\r
2123 core.logallrefupdates=true\r
2124 remote.origin.url=git://git.kernel.org/pub/scm/git/git.git\r
2125 remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*\r
2126 branch.master.remote=origin\r
2127 branch.master.merge=refs/heads/master</literallayout>\r
2128 <simpara>If there are other repositories that you also use frequently, you can\r
2129 create similar configuration options to save typing; for example,</simpara>\r
2130 <literallayout>$ git remote add example git://example.com/proj.git</literallayout>\r
2131 <simpara>adds the following to <emphasis>.git/config</emphasis>:</simpara>\r
2132 <literallayout>[remote "example"]\r
2133         url = git://example.com/proj.git\r
2134         fetch = +refs/heads/*:refs/remotes/example/*</literallayout>\r
2135 <simpara>Also note that the above configuration can be performed by directly\r
2136 editing the file <emphasis>.git/config</emphasis> instead of using <xref linkend="git-remote(1)" />.</simpara>\r
2137 <simpara>After configuring the remote, the following three commands will do the\r
2138 same thing:</simpara>\r
2139 <literallayout>$ git fetch git://example.com/proj.git +refs/heads/*:refs/remotes/example/*\r
2140 $ git fetch example +refs/heads/*:refs/remotes/example/*\r
2141 $ git fetch example</literallayout>\r
2142 <simpara>See <xref linkend="git-config(1)" /> for more details on the configuration\r
2143 options mentioned above and <xref linkend="git-fetch(1)" /> for more details on\r
2144 the refspec syntax.</simpara>\r
2145 </section>\r
2146 </section>\r
2147 <section id="Git User Manual_git-concepts">\r
2148 <title>Git concepts</title>\r
2149 <simpara>Git is built on a small number of simple but powerful ideas.  While it\r
2150 is possible to get things done without understanding them, you will find\r
2151 Git much more intuitive if you do.</simpara>\r
2152 <simpara>We start with the most important, the  <link linkend="Git User Manual_def_object_database">object database</link> and the <link linkend="Git User Manual_def_index">index</link>.</simpara>\r
2153 <section id="Git User Manual_the-object-database">\r
2154 <title>The Object Database</title>\r
2155 <simpara>We already saw in <xref linkend="Git User Manual_understanding-commits"/> that all commits are stored\r
2156 under a 40-digit "object name".  In fact, all the information needed to\r
2157 represent the history of a project is stored in objects with such names.\r
2158 In each case the name is calculated by taking the SHA-1 hash of the\r
2159 contents of the object.  The SHA-1 hash is a cryptographic hash function.\r
2160 What that means to us is that it is impossible to find two different\r
2161 objects with the same name.  This has a number of advantages; among\r
2162 others:</simpara>\r
2163 <itemizedlist>\r
2164 <listitem>\r
2165 <simpara>\r
2166 Git can quickly determine whether two objects are identical or not,\r
2167   just by comparing names.\r
2168 </simpara>\r
2169 </listitem>\r
2170 <listitem>\r
2171 <simpara>\r
2172 Since object names are computed the same way in every repository, the\r
2173   same content stored in two repositories will always be stored under\r
2174   the same name.\r
2175 </simpara>\r
2176 </listitem>\r
2177 <listitem>\r
2178 <simpara>\r
2179 Git can detect errors when it reads an object, by checking that the\r
2180   object's name is still the SHA-1 hash of its contents.\r
2181 </simpara>\r
2182 </listitem>\r
2183 </itemizedlist>\r
2184 <simpara>(See <xref linkend="Git User Manual_object-details"/> for the details of the object formatting and\r
2185 SHA-1 calculation.)</simpara>\r
2186 <simpara>There are four different types of objects: "blob", "tree", "commit", and\r
2187 "tag".</simpara>\r
2188 <itemizedlist>\r
2189 <listitem>\r
2190 <simpara>\r
2191 A <link linkend="Git User Manual_def_blob_object">"blob" object</link> is used to store file data.\r
2192 </simpara>\r
2193 </listitem>\r
2194 <listitem>\r
2195 <simpara>\r
2196 A <link linkend="Git User Manual_def_tree_object">"tree" object</link> ties one or more\r
2197   "blob" objects into a directory structure. In addition, a tree object\r
2198   can refer to other tree objects, thus creating a directory hierarchy.\r
2199 </simpara>\r
2200 </listitem>\r
2201 <listitem>\r
2202 <simpara>\r
2203 A <link linkend="Git User Manual_def_commit_object">"commit" object</link> ties such directory hierarchies\r
2204   together into a <link linkend="Git User Manual_def_DAG">directed acyclic graph</link> of revisions--each\r
2205   commit contains the object name of exactly one tree designating the\r
2206   directory hierarchy at the time of the commit. In addition, a commit\r
2207   refers to "parent" commit objects that describe the history of how we\r
2208   arrived at that directory hierarchy.\r
2209 </simpara>\r
2210 </listitem>\r
2211 <listitem>\r
2212 <simpara>\r
2213 A <link linkend="Git User Manual_def_tag_object">"tag" object</link> symbolically identifies and can be\r
2214   used to sign other objects. It contains the object name and type of\r
2215   another object, a symbolic name (of course!) and, optionally, a\r
2216   signature.\r
2217 </simpara>\r
2218 </listitem>\r
2219 </itemizedlist>\r
2220 <simpara>The object types in some more detail:</simpara>\r
2221 <section id="Git User Manual_commit-object">\r
2222 <title>Commit Object</title>\r
2223 <simpara>The "commit" object links a physical state of a tree with a description\r
2224 of how we got there and why.  Use the <emphasis>--pretty=raw</emphasis> option to\r
2225 <xref linkend="git-show(1)" /> or <xref linkend="git-log(1)" /> to examine your favorite\r
2226 commit:</simpara>\r
2227 <literallayout>$ git show -s --pretty=raw 2be7fcb476\r
2228 commit 2be7fcb4764f2dbcee52635b91fedb1b3dcf7ab4\r
2229 tree fb3a8bdd0ceddd019615af4d57a53f43d8cee2bf\r
2230 parent 257a84d9d02e90447b149af58b271c19405edb6a\r
2231 author Dave Watson &lt;dwatson@mimvista.com&gt; 1187576872 -0400\r
2232 committer Junio C Hamano &lt;gitster@pobox.com&gt; 1187591163 -0700\r
2234     Fix misspelling of 'suppress' in docs\r
2236     Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;</literallayout>\r
2237 <simpara>As you can see, a commit is defined by:</simpara>\r
2238 <itemizedlist>\r
2239 <listitem>\r
2240 <simpara>\r
2241 a tree: The SHA-1 name of a tree object (as defined below), representing\r
2242   the contents of a directory at a certain point in time.\r
2243 </simpara>\r
2244 </listitem>\r
2245 <listitem>\r
2246 <simpara>\r
2247 parent(s): The SHA-1 name(s) of some number of commits which represent the\r
2248   immediately previous step(s) in the history of the project.  The\r
2249   example above has one parent; merge commits may have more than\r
2250   one.  A commit with no parents is called a "root" commit, and\r
2251   represents the initial revision of a project.  Each project must have\r
2252   at least one root.  A project can also have multiple roots, though\r
2253   that isn't common (or necessarily a good idea).\r
2254 </simpara>\r
2255 </listitem>\r
2256 <listitem>\r
2257 <simpara>\r
2258 an author: The name of the person responsible for this change, together\r
2259   with its date.\r
2260 </simpara>\r
2261 </listitem>\r
2262 <listitem>\r
2263 <simpara>\r
2264 a committer: The name of the person who actually created the commit,\r
2265   with the date it was done.  This may be different from the author, for\r
2266   example, if the author was someone who wrote a patch and emailed it\r
2267   to the person who used it to create the commit.\r
2268 </simpara>\r
2269 </listitem>\r
2270 <listitem>\r
2271 <simpara>\r
2272 a comment describing this commit.\r
2273 </simpara>\r
2274 </listitem>\r
2275 </itemizedlist>\r
2276 <simpara>Note that a commit does not itself contain any information about what\r
2277 actually changed; all changes are calculated by comparing the contents\r
2278 of the tree referred to by this commit with the trees associated with\r
2279 its parents.  In particular, Git does not attempt to record file renames\r
2280 explicitly, though it can identify cases where the existence of the same\r
2281 file data at changing paths suggests a rename.  (See, for example, the\r
2282 <emphasis>-M</emphasis> option to <xref linkend="git-diff(1)" />).</simpara>\r
2283 <simpara>A commit is usually created by <xref linkend="git-commit(1)" />, which creates a\r
2284 commit whose parent is normally the current HEAD, and whose tree is\r
2285 taken from the content currently stored in the index.</simpara>\r
2286 </section>\r
2287 <section id="Git User Manual_tree-object">\r
2288 <title>Tree Object</title>\r
2289 <simpara>The ever-versatile <xref linkend="git-show(1)" /> command can also be used to\r
2290 examine tree objects, but <xref linkend="git-ls-tree(1)" /> will give you more\r
2291 details:</simpara>\r
2292 <literallayout>$ git ls-tree fb3a8bdd0ce\r
2293 100644 blob 63c918c667fa005ff12ad89437f2fdc80926e21c    .gitignore\r
2294 100644 blob 5529b198e8d14decbe4ad99db3f7fb632de0439d    .mailmap\r
2295 100644 blob 6ff87c4664981e4397625791c8ea3bbb5f2279a3    COPYING\r
2296 040000 tree 2fb783e477100ce076f6bf57e4a6f026013dc745    Documentation\r
2297 100755 blob 3c0032cec592a765692234f1cba47dfdcc3a9200    GIT-VERSION-GEN\r
2298 100644 blob 289b046a443c0647624607d471289b2c7dcd470b    INSTALL\r
2299 100644 blob 4eb463797adc693dc168b926b6932ff53f17d0b1    Makefile\r
2300 100644 blob 548142c327a6790ff8821d67c2ee1eff7a656b52    README\r
2301 ...</literallayout>\r
2302 <simpara>As you can see, a tree object contains a list of entries, each with a\r
2303 mode, object type, SHA-1 name, and name, sorted by name.  It represents\r
2304 the contents of a single directory tree.</simpara>\r
2305 <simpara>The object type may be a blob, representing the contents of a file, or\r
2306 another tree, representing the contents of a subdirectory.  Since trees\r
2307 and blobs, like all other objects, are named by the SHA-1 hash of their\r
2308 contents, two trees have the same SHA-1 name if and only if their\r
2309 contents (including, recursively, the contents of all subdirectories)\r
2310 are identical.  This allows Git to quickly determine the differences\r
2311 between two related tree objects, since it can ignore any entries with\r
2312 identical object names.</simpara>\r
2313 <simpara>(Note: in the presence of submodules, trees may also have commits as\r
2314 entries.  See <xref linkend="Git User Manual_submodules"/> for documentation.)</simpara>\r
2315 <simpara>Note that the files all have mode 644 or 755: Git actually only pays\r
2316 attention to the executable bit.</simpara>\r
2317 </section>\r
2318 <section id="Git User Manual_blob-object">\r
2319 <title>Blob Object</title>\r
2320 <simpara>You can use <xref linkend="git-show(1)" /> to examine the contents of a blob; take,\r
2321 for example, the blob in the entry for <emphasis>COPYING</emphasis> from the tree above:</simpara>\r
2322 <literallayout>$ git show 6ff87c4664\r
2324  Note that the only valid version of the GPL as far as this project\r
2325  is concerned is _this_ particular version of the license (ie v2, not\r
2326  v2.2 or v3.x or whatever), unless explicitly otherwise stated.\r
2327 ...</literallayout>\r
2328 <simpara>A "blob" object is nothing but a binary blob of data.  It doesn't refer\r
2329 to anything else or have attributes of any kind.</simpara>\r
2330 <simpara>Since the blob is entirely defined by its data, if two files in a\r
2331 directory tree (or in multiple different versions of the repository)\r
2332 have the same contents, they will share the same blob object. The object\r
2333 is totally independent of its location in the directory tree, and\r
2334 renaming a file does not change the object that file is associated with.</simpara>\r
2335 <simpara>Note that any tree or blob object can be examined using\r
2336 <xref linkend="git-show(1)" /> with the &lt;revision&gt;:&lt;path&gt; syntax.  This can\r
2337 sometimes be useful for browsing the contents of a tree that is not\r
2338 currently checked out.</simpara>\r
2339 </section>\r
2340 <section id="Git User Manual_trust">\r
2341 <title>Trust</title>\r
2342 <simpara>If you receive the SHA-1 name of a blob from one source, and its contents\r
2343 from another (possibly untrusted) source, you can still trust that those\r
2344 contents are correct as long as the SHA-1 name agrees.  This is because\r
2345 the SHA-1 is designed so that it is infeasible to find different contents\r
2346 that produce the same hash.</simpara>\r
2347 <simpara>Similarly, you need only trust the SHA-1 name of a top-level tree object\r
2348 to trust the contents of the entire directory that it refers to, and if\r
2349 you receive the SHA-1 name of a commit from a trusted source, then you\r
2350 can easily verify the entire history of commits reachable through\r
2351 parents of that commit, and all of those contents of the trees referred\r
2352 to by those commits.</simpara>\r
2353 <simpara>So to introduce some real trust in the system, the only thing you need\r
2354 to do is to digitally sign just <emphasis>one</emphasis> special note, which includes the\r
2355 name of a top-level commit.  Your digital signature shows others\r
2356 that you trust that commit, and the immutability of the history of\r
2357 commits tells others that they can trust the whole history.</simpara>\r
2358 <simpara>In other words, you can easily validate a whole archive by just\r
2359 sending out a single email that tells the people the name (SHA-1 hash)\r
2360 of the top commit, and digitally sign that email using something\r
2361 like GPG/PGP.</simpara>\r
2362 <simpara>To assist in this, Git also provides the tag object&#8230;</simpara>\r
2363 </section>\r
2364 <section id="Git User Manual_tag-object">\r
2365 <title>Tag Object</title>\r
2366 <simpara>A tag object contains an object, object type, tag name, the name of the\r
2367 person ("tagger") who created the tag, and a message, which may contain\r
2368 a signature, as can be seen using <xref linkend="git-cat-file(1)" />:</simpara>\r
2369 <literallayout>$ git cat-file tag v1.5.0\r
2370 object 437b1b20df4b356c9342dac8d38849f24ef44f27\r
2371 type commit\r
2372 tag v1.5.0\r
2373 tagger Junio C Hamano &lt;junkio@cox.net&gt; 1171411200 +0000\r
2375 GIT 1.5.0\r
2376 -----BEGIN PGP SIGNATURE-----\r
2377 Version: GnuPG v1.4.6 (GNU/Linux)\r
2379 iD8DBQBF0lGqwMbZpPMRm5oRAuRiAJ9ohBLd7s2kqjkKlq1qqC57SbnmzQCdG4ui\r
2380 nLE/L9aUXdWeTFPron96DLA=\r
2381 =2E+0\r
2382 -----END PGP SIGNATURE-----</literallayout>\r
2383 <simpara>See the <xref linkend="git-tag(1)" /> command to learn how to create and verify tag\r
2384 objects.  (Note that <xref linkend="git-tag(1)" /> can also be used to create\r
2385 "lightweight tags", which are not tag objects at all, but just simple\r
2386 references whose names begin with <emphasis>refs/tags/</emphasis>).</simpara>\r
2387 </section>\r
2388 <section id="Git User Manual_pack-files">\r
2389 <title>How Git stores objects efficiently: pack files</title>\r
2390 <simpara>Newly created objects are initially created in a file named after the\r
2391 object's SHA-1 hash (stored in <emphasis>.git/objects</emphasis>).</simpara>\r
2392 <simpara>Unfortunately this system becomes inefficient once a project has a\r
2393 lot of objects.  Try this on an old project:</simpara>\r
2394 <literallayout>$ git count-objects\r
2395 6930 objects, 47620 kilobytes</literallayout>\r
2396 <simpara>The first number is the number of objects which are kept in\r
2397 individual files.  The second is the amount of space taken up by\r
2398 those "loose" objects.</simpara>\r
2399 <simpara>You can save space and make Git faster by moving these loose objects in\r
2400 to a "pack file", which stores a group of objects in an efficient\r
2401 compressed format; the details of how pack files are formatted can be\r
2402 found in link:technical/pack-format.html[pack format].</simpara>\r
2403 <simpara>To put the loose objects into a pack, just run git repack:</simpara>\r
2404 <literallayout>$ git repack\r
2405 Counting objects: 6020, done.\r
2406 Delta compression using up to 4 threads.\r
2407 Compressing objects: 100% (6020/6020), done.\r
2408 Writing objects: 100% (6020/6020), done.\r
2409 Total 6020 (delta 4070), reused 0 (delta 0)</literallayout>\r
2410 <simpara>This creates a single "pack file" in .git/objects/pack/\r
2411 containing all currently unpacked objects.  You can then run</simpara>\r
2412 <literallayout>$ git prune</literallayout>\r
2413 <simpara>to remove any of the "loose" objects that are now contained in the\r
2414 pack.  This will also remove any unreferenced objects (which may be\r
2415 created when, for example, you use <emphasis>git reset</emphasis> to remove a commit).\r
2416 You can verify that the loose objects are gone by looking at the\r
2417 <emphasis>.git/objects</emphasis> directory or by running</simpara>\r
2418 <literallayout>$ git count-objects\r
2419 0 objects, 0 kilobytes</literallayout>\r
2420 <simpara>Although the object files are gone, any commands that refer to those\r
2421 objects will work exactly as they did before.</simpara>\r
2422 <simpara>The <xref linkend="git-gc(1)" /> command performs packing, pruning, and more for\r
2423 you, so is normally the only high-level command you need.</simpara>\r
2424 </section>\r
2425 <section id="Git User Manual_dangling-objects">\r
2426 <title>Dangling objects</title>\r
2427 <simpara>The <xref linkend="git-fsck(1)" /> command will sometimes complain about dangling\r
2428 objects.  They are not a problem.</simpara>\r
2429 <simpara>The most common cause of dangling objects is that you've rebased a\r
2430 branch, or you have pulled from somebody else who rebased a branch--see\r
2431 <xref linkend="Git User Manual_cleaning-up-history"/>.  In that case, the old head of the original\r
2432 branch still exists, as does everything it pointed to. The branch\r
2433 pointer itself just doesn't, since you replaced it with another one.</simpara>\r
2434 <simpara>There are also other situations that cause dangling objects. For\r
2435 example, a "dangling blob" may arise because you did a <emphasis>git add</emphasis> of a\r
2436 file, but then, before you actually committed it and made it part of the\r
2437 bigger picture, you changed something else in that file and committed\r
2438 that <emphasis role="strong">updated</emphasis> thing--the old state that you added originally ends up\r
2439 not being pointed to by any commit or tree, so it's now a dangling blob\r
2440 object.</simpara>\r
2441 <simpara>Similarly, when the "recursive" merge strategy runs, and finds that\r
2442 there are criss-cross merges and thus more than one merge base (which is\r
2443 fairly unusual, but it does happen), it will generate one temporary\r
2444 midway tree (or possibly even more, if you had lots of criss-crossing\r
2445 merges and more than two merge bases) as a temporary internal merge\r
2446 base, and again, those are real objects, but the end result will not end\r
2447 up pointing to them, so they end up "dangling" in your repository.</simpara>\r
2448 <simpara>Generally, dangling objects aren't anything to worry about. They can\r
2449 even be very useful: if you screw something up, the dangling objects can\r
2450 be how you recover your old tree (say, you did a rebase, and realized\r
2451 that you really didn't want to--you can look at what dangling objects\r
2452 you have, and decide to reset your head to some old dangling state).</simpara>\r
2453 <simpara>For commits, you can just use:</simpara>\r
2454 <literallayout>$ gitk &lt;dangling-commit-sha-goes-here&gt; --not --all</literallayout>\r
2455 <simpara>This asks for all the history reachable from the given commit but not\r
2456 from any branch, tag, or other reference.  If you decide it's something\r
2457 you want, you can always create a new reference to it, e.g.,</simpara>\r
2458 <literallayout>$ git branch recovered-branch &lt;dangling-commit-sha-goes-here&gt;</literallayout>\r
2459 <simpara>For blobs and trees, you can't do the same, but you can still examine\r
2460 them.  You can just do</simpara>\r
2461 <literallayout>$ git show &lt;dangling-blob/tree-sha-goes-here&gt;</literallayout>\r
2462 <simpara>to show what the contents of the blob were (or, for a tree, basically\r
2463 what the <emphasis>ls</emphasis> for that directory was), and that may give you some idea\r
2464 of what the operation was that left that dangling object.</simpara>\r
2465 <simpara>Usually, dangling blobs and trees aren't very interesting. They're\r
2466 almost always the result of either being a half-way mergebase (the blob\r
2467 will often even have the conflict markers from a merge in it, if you\r
2468 have had conflicting merges that you fixed up by hand), or simply\r
2469 because you interrupted a <emphasis>git fetch</emphasis> with ^C or something like that,\r
2470 leaving <emphasis>some</emphasis> of the new objects in the object database, but just\r
2471 dangling and useless.</simpara>\r
2472 <simpara>Anyway, once you are sure that you're not interested in any dangling\r
2473 state, you can just prune all unreachable objects:</simpara>\r
2474 <literallayout>$ git prune</literallayout>\r
2475 <simpara>and they'll be gone. (You should only run <emphasis>git prune</emphasis> on a quiescent\r
2476 repository--it's kind of like doing a filesystem fsck recovery: you\r
2477 don't want to do that while the filesystem is mounted.\r
2478 <emphasis>git prune</emphasis> is designed not to cause any harm in such cases of concurrent\r
2479 accesses to a repository but you might receive confusing or scary messages.)</simpara>\r
2480 </section>\r
2481 <section id="Git User Manual_recovering-from-repository-corruption">\r
2482 <title>Recovering from repository corruption</title>\r
2483 <simpara>By design, Git treats data trusted to it with caution.  However, even in\r
2484 the absence of bugs in Git itself, it is still possible that hardware or\r
2485 operating system errors could corrupt data.</simpara>\r
2486 <simpara>The first defense against such problems is backups.  You can back up a\r
2487 Git directory using clone, or just using cp, tar, or any other backup\r
2488 mechanism.</simpara>\r
2489 <simpara>As a last resort, you can search for the corrupted objects and attempt\r
2490 to replace them by hand.  Back up your repository before attempting this\r
2491 in case you corrupt things even more in the process.</simpara>\r
2492 <simpara>We'll assume that the problem is a single missing or corrupted blob,\r
2493 which is sometimes a solvable problem.  (Recovering missing trees and\r
2494 especially commits is <emphasis role="strong">much</emphasis> harder).</simpara>\r
2495 <simpara>Before starting, verify that there is corruption, and figure out where\r
2496 it is with <xref linkend="git-fsck(1)" />; this may be time-consuming.</simpara>\r
2497 <simpara>Assume the output looks like this:</simpara>\r
2498 <literallayout>$ git fsck --full --no-dangling\r
2499 broken link from    tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8\r
2500               to    blob 4b9458b3786228369c63936db65827de3cc06200\r
2501 missing blob 4b9458b3786228369c63936db65827de3cc06200</literallayout>\r
2502 <simpara>Now you know that blob 4b9458b3 is missing, and that the tree 2d9263c6\r
2503 points to it.  If you could find just one copy of that missing blob\r
2504 object, possibly in some other repository, you could move it into\r
2505 <emphasis>.git/objects/4b/9458b3...</emphasis> and be done.  Suppose you can't.  You can\r
2506 still examine the tree that pointed to it with <xref linkend="git-ls-tree(1)" />,\r
2507 which might output something like:</simpara>\r
2508 <literallayout>$ git ls-tree 2d9263c6d23595e7cb2a21e5ebbb53655278dff8\r
2509 100644 blob 8d14531846b95bfa3564b58ccfb7913a034323b8    .gitignore\r
2510 100644 blob ebf9bf84da0aab5ed944264a5db2a65fe3a3e883    .mailmap\r
2511 100644 blob ca442d313d86dc67e0a2e5d584b465bd382cbf5c    COPYING\r
2512 ...\r
2513 100644 blob 4b9458b3786228369c63936db65827de3cc06200    myfile\r
2514 ...</literallayout>\r
2515 <simpara>So now you know that the missing blob was the data for a file named\r
2516 <emphasis>myfile</emphasis>.  And chances are you can also identify the directory--let's\r
2517 say it's in <emphasis>somedirectory</emphasis>.  If you're lucky the missing copy might be\r
2518 the same as the copy you have checked out in your working tree at\r
2519 <emphasis>somedirectory/myfile</emphasis>; you can test whether that's right with\r
2520 <xref linkend="git-hash-object(1)" />:</simpara>\r
2521 <literallayout>$ git hash-object -w somedirectory/myfile</literallayout>\r
2522 <simpara>which will create and store a blob object with the contents of\r
2523 somedirectory/myfile, and output the SHA-1 of that object.  if you're\r
2524 extremely lucky it might be 4b9458b3786228369c63936db65827de3cc06200, in\r
2525 which case you've guessed right, and the corruption is fixed!</simpara>\r
2526 <simpara>Otherwise, you need more information.  How do you tell which version of\r
2527 the file has been lost?</simpara>\r
2528 <simpara>The easiest way to do this is with:</simpara>\r
2529 <literallayout>$ git log --raw --all --full-history -- somedirectory/myfile</literallayout>\r
2530 <simpara>Because you're asking for raw output, you'll now get something like</simpara>\r
2531 <literallayout>commit abc\r
2532 Author:\r
2533 Date:\r
2534 ...\r
2535 :100644 100644 4b9458b... newsha... M somedirectory/myfile\r
2538 commit xyz\r
2539 Author:\r
2540 Date:\r
2542 ...\r
2543 :100644 100644 oldsha... 4b9458b... M somedirectory/myfile</literallayout>\r
2544 <simpara>This tells you that the immediately following version of the file was\r
2545 "newsha", and that the immediately preceding version was "oldsha".\r
2546 You also know the commit messages that went with the change from oldsha\r
2547 to 4b9458b and with the change from 4b9458b to newsha.</simpara>\r
2548 <simpara>If you've been committing small enough changes, you may now have a good\r
2549 shot at reconstructing the contents of the in-between state 4b9458b.</simpara>\r
2550 <simpara>If you can do that, you can now recreate the missing object with</simpara>\r
2551 <literallayout>$ git hash-object -w &lt;recreated-file&gt;</literallayout>\r
2552 <simpara>and your repository is good again!</simpara>\r
2553 <simpara>(Btw, you could have ignored the <emphasis>fsck</emphasis>, and started with doing a</simpara>\r
2554 <literallayout>$ git log --raw --all</literallayout>\r
2555 <simpara>and just looked for the sha of the missing object (4b9458b..) in that\r
2556 whole thing. It's up to you--Git does <emphasis role="strong">have</emphasis> a lot of information, it is\r
2557 just missing one particular blob version.</simpara>\r
2558 </section>\r
2559 </section>\r
2560 <section id="Git User Manual_the-index">\r
2561 <title>The index</title>\r
2562 <simpara>The index is a binary file (generally kept in <emphasis>.git/index</emphasis>) containing a\r
2563 sorted list of path names, each with permissions and the SHA-1 of a blob\r
2564 object; <xref linkend="git-ls-files(1)" /> can show you the contents of the index:</simpara>\r
2565 <literallayout>$ git ls-files --stage\r
2566 100644 63c918c667fa005ff12ad89437f2fdc80926e21c 0       .gitignore\r
2567 100644 5529b198e8d14decbe4ad99db3f7fb632de0439d 0       .mailmap\r
2568 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 0       COPYING\r
2569 100644 a37b2152bd26be2c2289e1f57a292534a51a93c7 0       Documentation/.gitignore\r
2570 100644 fbefe9a45b00a54b58d94d06eca48b03d40a50e0 0       Documentation/Makefile\r
2571 ...\r
2572 100644 2511aef8d89ab52be5ec6a5e46236b4b6bcd07ea 0       xdiff/xtypes.h\r
2573 100644 2ade97b2574a9f77e7ae4002a4e07a6a38e46d07 0       xdiff/xutils.c\r
2574 100644 d5de8292e05e7c36c4b68857c1cf9855e3d2f70a 0       xdiff/xutils.h</literallayout>\r
2575 <simpara>Note that in older documentation you may see the index called the\r
2576 "current directory cache" or just the "cache".  It has three important\r
2577 properties:</simpara>\r
2578 <orderedlist numeration="arabic">\r
2579 <listitem>\r
2580 <simpara>\r
2581 The index contains all the information necessary to generate a single\r
2582 (uniquely determined) tree object.\r
2583 </simpara>\r
2584 <simpara>For example, running <xref linkend="git-commit(1)" /> generates this tree object\r
2585 from the index, stores it in the object database, and uses it as the\r
2586 tree object associated with the new commit.</simpara>\r
2587 </listitem>\r
2588 <listitem>\r
2589 <simpara>\r
2590 The index enables fast comparisons between the tree object it defines\r
2591 and the working tree.\r
2592 </simpara>\r
2593 <simpara>It does this by storing some additional data for each entry (such as\r
2594 the last modified time).  This data is not displayed above, and is not\r
2595 stored in the created tree object, but it can be used to determine\r
2596 quickly which files in the working directory differ from what was\r
2597 stored in the index, and thus save Git from having to read all of the\r
2598 data from such files to look for changes.</simpara>\r
2599 </listitem>\r
2600 <listitem>\r
2601 <simpara>\r
2602 It can efficiently represent information about merge conflicts\r
2603 between different tree objects, allowing each pathname to be\r
2604 associated with sufficient information about the trees involved that\r
2605 you can create a three-way merge between them.\r
2606 </simpara>\r
2607 <simpara>We saw in <xref linkend="Git User Manual_conflict-resolution"/> that during a merge the index can\r
2608 store multiple versions of a single file (called "stages").  The third\r
2609 column in the <xref linkend="git-ls-files(1)" /> output above is the stage\r
2610 number, and will take on values other than 0 for files with merge\r
2611 conflicts.</simpara>\r
2612 </listitem>\r
2613 </orderedlist>\r
2614 <simpara>The index is thus a sort of temporary staging area, which is filled with\r
2615 a tree which you are in the process of working on.</simpara>\r
2616 <simpara>If you blow the index away entirely, you generally haven't lost any\r
2617 information as long as you have the name of the tree that it described.</simpara>\r
2618 </section>\r
2619 </section>\r
2620 <section id="Git User Manual_submodules">\r
2621 <title>Submodules</title>\r
2622 <simpara>Large projects are often composed of smaller, self-contained modules.  For\r
2623 example, an embedded Linux distribution's source tree would include every\r
2624 piece of software in the distribution with some local modifications; a movie\r
2625 player might need to build against a specific, known-working version of a\r
2626 decompression library; several independent programs might all share the same\r
2627 build scripts.</simpara>\r
2628 <simpara>With centralized revision control systems this is often accomplished by\r
2629 including every module in one single repository.  Developers can check out\r
2630 all modules or only the modules they need to work with.  They can even modify\r
2631 files across several modules in a single commit while moving things around\r
2632 or updating APIs and translations.</simpara>\r
2633 <simpara>Git does not allow partial checkouts, so duplicating this approach in Git\r
2634 would force developers to keep a local copy of modules they are not\r
2635 interested in touching.  Commits in an enormous checkout would be slower\r
2636 than you'd expect as Git would have to scan every directory for changes.\r
2637 If modules have a lot of local history, clones would take forever.</simpara>\r
2638 <simpara>On the plus side, distributed revision control systems can much better\r
2639 integrate with external sources.  In a centralized model, a single arbitrary\r
2640 snapshot of the external project is exported from its own revision control\r
2641 and then imported into the local revision control on a vendor branch.  All\r
2642 the history is hidden.  With distributed revision control you can clone the\r
2643 entire external history and much more easily follow development and re-merge\r
2644 local changes.</simpara>\r
2645 <simpara>Git's submodule support allows a repository to contain, as a subdirectory, a\r
2646 checkout of an external project.  Submodules maintain their own identity;\r
2647 the submodule support just stores the submodule repository location and\r
2648 commit ID, so other developers who clone the containing project\r
2649 ("superproject") can easily clone all the submodules at the same revision.\r
2650 Partial checkouts of the superproject are possible: you can tell Git to\r
2651 clone none, some or all of the submodules.</simpara>\r
2652 <simpara>The <xref linkend="git-submodule(1)" /> command is available since Git 1.5.3.  Users\r
2653 with Git 1.5.2 can look up the submodule commits in the repository and\r
2654 manually check them out; earlier versions won't recognize the submodules at\r
2655 all.</simpara>\r
2656 <simpara>To see how submodule support works, create four example\r
2657 repositories that can be used later as a submodule:</simpara>\r
2658 <literallayout>$ mkdir ~/git\r
2659 $ cd ~/git\r
2660 $ for i in a b c d\r
2661 do\r
2662         mkdir $i\r
2663         cd $i\r
2664         git init\r
2665         echo "module $i" &gt; $i.txt\r
2666         git add $i.txt\r
2667         git commit -m "Initial commit, submodule $i"\r
2668         cd ..\r
2669 done</literallayout>\r
2670 <simpara>Now create the superproject and add all the submodules:</simpara>\r
2671 <literallayout>$ mkdir super\r
2672 $ cd super\r
2673 $ git init\r
2674 $ for i in a b c d\r
2675 do\r
2676         git submodule add ~/git/$i $i\r
2677 done</literallayout>\r
2678 <note><simpara>Do not use local URLs here if you plan to publish your superproject!</simpara></note>\r
2679 <simpara>See what files <emphasis>git submodule</emphasis> created:</simpara>\r
2680 <literallayout>$ ls -a\r
2681 .  ..  .git  .gitmodules  a  b  c  d</literallayout>\r
2682 <simpara>The <emphasis>git submodule add &lt;repo&gt; &lt;path&gt;</emphasis> command does a couple of things:</simpara>\r
2683 <itemizedlist>\r
2684 <listitem>\r
2685 <simpara>\r
2686 It clones the submodule from <emphasis>&lt;repo&gt;</emphasis> to the given <emphasis>&lt;path&gt;</emphasis> under the\r
2687   current directory and by default checks out the master branch.\r
2688 </simpara>\r
2689 </listitem>\r
2690 <listitem>\r
2691 <simpara>\r
2692 It adds the submodule's clone path to the <xref linkend="gitmodules(5)" /> file and\r
2693   adds this file to the index, ready to be committed.\r
2694 </simpara>\r
2695 </listitem>\r
2696 <listitem>\r
2697 <simpara>\r
2698 It adds the submodule's current commit ID to the index, ready to be\r
2699   committed.\r
2700 </simpara>\r
2701 </listitem>\r
2702 </itemizedlist>\r
2703 <simpara>Commit the superproject:</simpara>\r
2704 <literallayout>$ git commit -m "Add submodules a, b, c and d."</literallayout>\r
2705 <simpara>Now clone the superproject:</simpara>\r
2706 <literallayout>$ cd ..\r
2707 $ git clone super cloned\r
2708 $ cd cloned</literallayout>\r
2709 <simpara>The submodule directories are there, but they're empty:</simpara>\r
2710 <literallayout>$ ls -a a\r
2711 .  ..\r
2712 $ git submodule status\r
2713 -d266b9873ad50488163457f025db7cdd9683d88b a\r
2714 -e81d457da15309b4fef4249aba9b50187999670d b\r
2715 -c1536a972b9affea0f16e0680ba87332dc059146 c\r
2716 -d96249ff5d57de5de093e6baff9e0aafa5276a74 d</literallayout>\r
2717 <note><simpara>The commit object names shown above would be different for you, but they\r
2718 should match the HEAD commit object names of your repositories.  You can check\r
2719 it by running <emphasis>git ls-remote ../a</emphasis>.</simpara></note>\r
2720 <simpara>Pulling down the submodules is a two-step process. First run <emphasis>git submodule\r
2721 init</emphasis> to add the submodule repository URLs to <emphasis>.git/config</emphasis>:</simpara>\r
2722 <literallayout>$ git submodule init</literallayout>\r
2723 <simpara>Now use <emphasis>git submodule update</emphasis> to clone the repositories and check out the\r
2724 commits specified in the superproject:</simpara>\r
2725 <literallayout>$ git submodule update\r
2726 $ cd a\r
2727 $ ls -a\r
2728 .  ..  .git  a.txt</literallayout>\r
2729 <simpara>One major difference between <emphasis>git submodule update</emphasis> and <emphasis>git submodule add</emphasis> is\r
2730 that <emphasis>git submodule update</emphasis> checks out a specific commit, rather than the tip\r
2731 of a branch. It's like checking out a tag: the head is detached, so you're not\r
2732 working on a branch.</simpara>\r
2733 <literallayout>$ git branch\r
2734 * (detached from d266b98)\r
2735   master</literallayout>\r
2736 <simpara>If you want to make a change within a submodule and you have a detached head,\r
2737 then you should create or checkout a branch, make your changes, publish the\r
2738 change within the submodule, and then update the superproject to reference the\r
2739 new commit:</simpara>\r
2740 <literallayout>$ git checkout master</literallayout>\r
2741 <simpara>or</simpara>\r
2742 <literallayout>$ git checkout -b fix-up</literallayout>\r
2743 <simpara>then</simpara>\r
2744 <literallayout>$ echo "adding a line again" &gt;&gt; a.txt\r
2745 $ git commit -a -m "Updated the submodule from within the superproject."\r
2746 $ git push\r
2747 $ cd ..\r
2748 $ git diff\r
2749 diff --git a/a b/a\r
2750 index d266b98..261dfac 160000\r
2751 --- a/a\r
2752 +++ b/a\r
2753 @@ -1 +1 @@\r
2754 -Subproject commit d266b9873ad50488163457f025db7cdd9683d88b\r
2755 +Subproject commit 261dfac35cb99d380eb966e102c1197139f7fa24\r
2756 $ git add a\r
2757 $ git commit -m "Updated submodule a."\r
2758 $ git push</literallayout>\r
2759 <simpara>You have to run <emphasis>git submodule update</emphasis> after <emphasis>git pull</emphasis> if you want to update\r
2760 submodules, too.</simpara>\r
2761 <section id="Git User Manual__pitfalls_with_submodules">\r
2762 <title>Pitfalls with submodules</title>\r
2763 <simpara>Always publish the submodule change before publishing the change to the\r
2764 superproject that references it. If you forget to publish the submodule change,\r
2765 others won't be able to clone the repository:</simpara>\r
2766 <literallayout>$ cd ~/git/super/a\r
2767 $ echo i added another line to this file &gt;&gt; a.txt\r
2768 $ git commit -a -m "doing it wrong this time"\r
2769 $ cd ..\r
2770 $ git add a\r
2771 $ git commit -m "Updated submodule a again."\r
2772 $ git push\r
2773 $ cd ~/git/cloned\r
2774 $ git pull\r
2775 $ git submodule update\r
2776 error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\r
2777 Did you forget to 'git add'?\r
2778 Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'</literallayout>\r
2779 <simpara>In older Git versions it could be easily forgotten to commit new or modified\r
2780 files in a submodule, which silently leads to similar problems as not pushing\r
2781 the submodule changes. Starting with Git 1.7.0 both <emphasis>git status</emphasis> and <emphasis>git diff</emphasis>\r
2782 in the superproject show submodules as modified when they contain new or\r
2783 modified files to protect against accidentally committing such a state. <emphasis>git\r
2784 diff</emphasis> will also add a <emphasis>-dirty</emphasis> to the work tree side when generating patch\r
2785 output or used with the <emphasis>--submodule</emphasis> option:</simpara>\r
2786 <literallayout>$ git diff\r
2787 diff --git a/sub b/sub\r
2788 --- a/sub\r
2789 +++ b/sub\r
2790 @@ -1 +1 @@\r
2791 -Subproject commit 3f356705649b5d566d97ff843cf193359229a453\r
2792 +Subproject commit 3f356705649b5d566d97ff843cf193359229a453-dirty\r
2793 $ git diff --submodule\r
2794 Submodule sub 3f35670..3f35670-dirty:</literallayout>\r
2795 <simpara>You also should not rewind branches in a submodule beyond commits that were\r
2796 ever recorded in any superproject.</simpara>\r
2797 <simpara>It's not safe to run <emphasis>git submodule update</emphasis> if you've made and committed\r
2798 changes within a submodule without checking out a branch first. They will be\r
2799 silently overwritten:</simpara>\r
2800 <literallayout>$ cat a.txt\r
2801 module a\r
2802 $ echo line added from private2 &gt;&gt; a.txt\r
2803 $ git commit -a -m "line added inside private2"\r
2804 $ cd ..\r
2805 $ git submodule update\r
2806 Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b'\r
2807 $ cd a\r
2808 $ cat a.txt\r
2809 module a</literallayout>\r
2810 <note><simpara>The changes are still visible in the submodule's reflog.</simpara></note>\r
2811 <simpara>If you have uncommitted changes in your submodule working tree, <emphasis>git\r
2812 submodule update</emphasis> will not overwrite them.  Instead, you get the usual\r
2813 warning about not being able switch from a dirty branch.</simpara>\r
2814 </section>\r
2815 </section>\r
2816 <section id="Git User Manual_low-level-operations">\r
2817 <title>Low-level Git operations</title>\r
2818 <simpara>Many of the higher-level commands were originally implemented as shell\r
2819 scripts using a smaller core of low-level Git commands.  These can still\r
2820 be useful when doing unusual things with Git, or just as a way to\r
2821 understand its inner workings.</simpara>\r
2822 <section id="Git User Manual_object-manipulation">\r
2823 <title>Object access and manipulation</title>\r
2824 <simpara>The <xref linkend="git-cat-file(1)" /> command can show the contents of any object,\r
2825 though the higher-level <xref linkend="git-show(1)" /> is usually more useful.</simpara>\r
2826 <simpara>The <xref linkend="git-commit-tree(1)" /> command allows constructing commits with\r
2827 arbitrary parents and trees.</simpara>\r
2828 <simpara>A tree can be created with <xref linkend="git-write-tree(1)" /> and its data can be\r
2829 accessed by <xref linkend="git-ls-tree(1)" />.  Two trees can be compared with\r
2830 <xref linkend="git-diff-tree(1)" />.</simpara>\r
2831 <simpara>A tag is created with <xref linkend="git-mktag(1)" />, and the signature can be\r
2832 verified by <xref linkend="git-verify-tag(1)" />, though it is normally simpler to\r
2833 use <xref linkend="git-tag(1)" /> for both.</simpara>\r
2834 </section>\r
2835 <section id="Git User Manual_the-workflow">\r
2836 <title>The Workflow</title>\r
2837 <simpara>High-level operations such as <xref linkend="git-commit(1)" />,\r
2838 <xref linkend="git-checkout(1)" /> and <xref linkend="git-reset(1)" /> work by moving data\r
2839 between the working tree, the index, and the object database.  Git\r
2840 provides low-level operations which perform each of these steps\r
2841 individually.</simpara>\r
2842 <simpara>Generally, all Git operations work on the index file. Some operations\r
2843 work <emphasis role="strong">purely</emphasis> on the index file (showing the current state of the\r
2844 index), but most operations move data between the index file and either\r
2845 the database or the working directory. Thus there are four main\r
2846 combinations:</simpara>\r
2847 <section id="Git User Manual_working-directory-to-index">\r
2848 <title>working directory &#8594; index</title>\r
2849 <simpara>The <xref linkend="git-update-index(1)" /> command updates the index with\r
2850 information from the working directory.  You generally update the\r
2851 index information by just specifying the filename you want to update,\r
2852 like so:</simpara>\r
2853 <literallayout>$ git update-index filename</literallayout>\r
2854 <simpara>but to avoid common mistakes with filename globbing etc., the command\r
2855 will not normally add totally new entries or remove old entries,\r
2856 i.e. it will normally just update existing cache entries.</simpara>\r
2857 <simpara>To tell Git that yes, you really do realize that certain files no\r
2858 longer exist, or that new files should be added, you\r
2859 should use the <emphasis>--remove</emphasis> and <emphasis>--add</emphasis> flags respectively.</simpara>\r
2860 <simpara>NOTE! A <emphasis>--remove</emphasis> flag does <emphasis>not</emphasis> mean that subsequent filenames will\r
2861 necessarily be removed: if the files still exist in your directory\r
2862 structure, the index will be updated with their new status, not\r
2863 removed. The only thing <emphasis>--remove</emphasis> means is that update-index will be\r
2864 considering a removed file to be a valid thing, and if the file really\r
2865 does not exist any more, it will update the index accordingly.</simpara>\r
2866 <simpara>As a special case, you can also do <emphasis>git update-index --refresh</emphasis>, which\r
2867 will refresh the "stat" information of each index to match the current\r
2868 stat information. It will <emphasis>not</emphasis> update the object status itself, and\r
2869 it will only update the fields that are used to quickly test whether\r
2870 an object still matches its old backing store object.</simpara>\r
2871 <simpara>The previously introduced <xref linkend="git-add(1)" /> is just a wrapper for\r
2872 <xref linkend="git-update-index(1)" />.</simpara>\r
2873 </section>\r
2874 <section id="Git User Manual_index-to-object-database">\r
2875 <title>index &#8594; object database</title>\r
2876 <simpara>You write your current index file to a "tree" object with the program</simpara>\r
2877 <literallayout>$ git write-tree</literallayout>\r
2878 <simpara>that doesn't come with any options--it will just write out the\r
2879 current index into the set of tree objects that describe that state,\r
2880 and it will return the name of the resulting top-level tree. You can\r
2881 use that tree to re-generate the index at any time by going in the\r
2882 other direction:</simpara>\r
2883 </section>\r
2884 <section id="Git User Manual_object-database-to-index">\r
2885 <title>object database &#8594; index</title>\r
2886 <simpara>You read a "tree" file from the object database, and use that to\r
2887 populate (and overwrite--don't do this if your index contains any\r
2888 unsaved state that you might want to restore later!) your current\r
2889 index.  Normal operation is just</simpara>\r
2890 <literallayout>$ git read-tree &lt;SHA-1 of tree&gt;</literallayout>\r
2891 <simpara>and your index file will now be equivalent to the tree that you saved\r
2892 earlier. However, that is only your <emphasis>index</emphasis> file: your working\r
2893 directory contents have not been modified.</simpara>\r
2894 </section>\r
2895 <section id="Git User Manual_index-to-working-directory">\r
2896 <title>index &#8594; working directory</title>\r
2897 <simpara>You update your working directory from the index by "checking out"\r
2898 files. This is not a very common operation, since normally you'd just\r
2899 keep your files updated, and rather than write to your working\r
2900 directory, you'd tell the index files about the changes in your\r
2901 working directory (i.e. <emphasis>git update-index</emphasis>).</simpara>\r
2902 <simpara>However, if you decide to jump to a new version, or check out somebody\r
2903 else's version, or just restore a previous tree, you'd populate your\r
2904 index file with read-tree, and then you need to check out the result\r
2905 with</simpara>\r
2906 <literallayout>$ git checkout-index filename</literallayout>\r
2907 <simpara>or, if you want to check out all of the index, use <emphasis>-a</emphasis>.</simpara>\r
2908 <simpara>NOTE! <emphasis>git checkout-index</emphasis> normally refuses to overwrite old files, so\r
2909 if you have an old version of the tree already checked out, you will\r
2910 need to use the <emphasis>-f</emphasis> flag (<emphasis>before</emphasis> the <emphasis>-a</emphasis> flag or the filename) to\r
2911 <emphasis>force</emphasis> the checkout.</simpara>\r
2912 <simpara>Finally, there are a few odds and ends which are not purely moving\r
2913 from one representation to the other:</simpara>\r
2914 </section>\r
2915 <section id="Git User Manual_tying-it-all-together">\r
2916 <title>Tying it all together</title>\r
2917 <simpara>To commit a tree you have instantiated with <emphasis>git write-tree</emphasis>, you'd\r
2918 create a "commit" object that refers to that tree and the history\r
2919 behind it--most notably the "parent" commits that preceded it in\r
2920 history.</simpara>\r
2921 <simpara>Normally a "commit" has one parent: the previous state of the tree\r
2922 before a certain change was made. However, sometimes it can have two\r
2923 or more parent commits, in which case we call it a "merge", due to the\r
2924 fact that such a commit brings together ("merges") two or more\r
2925 previous states represented by other commits.</simpara>\r
2926 <simpara>In other words, while a "tree" represents a particular directory state\r
2927 of a working directory, a "commit" represents that state in time,\r
2928 and explains how we got there.</simpara>\r
2929 <simpara>You create a commit object by giving it the tree that describes the\r
2930 state at the time of the commit, and a list of parents:</simpara>\r
2931 <literallayout>$ git commit-tree &lt;tree&gt; -p &lt;parent&gt; [(-p &lt;parent2&gt;)...]</literallayout>\r
2932 <simpara>and then giving the reason for the commit on stdin (either through\r
2933 redirection from a pipe or file, or by just typing it at the tty).</simpara>\r
2934 <simpara><emphasis>git commit-tree</emphasis> will return the name of the object that represents\r
2935 that commit, and you should save it away for later use. Normally,\r
2936 you'd commit a new <emphasis>HEAD</emphasis> state, and while Git doesn't care where you\r
2937 save the note about that state, in practice we tend to just write the\r
2938 result to the file pointed at by <emphasis>.git/HEAD</emphasis>, so that we can always see\r
2939 what the last committed state was.</simpara>\r
2940 <simpara>Here is a picture that illustrates how various pieces fit together:</simpara>\r
2941 <literallayout>                     commit-tree\r
2942                       commit obj\r
2943                        +----+\r
2944                        |    |\r
2945                        |    |\r
2946                        V    V\r
2947                     +-----------+\r
2948                     | Object DB |\r
2949                     |  Backing  |\r
2950                     |   Store   |\r
2951                     +-----------+\r
2952                        ^\r
2953            write-tree  |     |\r
2954              tree obj  |     |\r
2955                        |     |  read-tree\r
2956                        |     |  tree obj\r
2957                              V\r
2958                     +-----------+\r
2959                     |   Index   |\r
2960                     |  "cache"  |\r
2961                     +-----------+\r
2962          update-index  ^\r
2963              blob obj  |     |\r
2964                        |     |\r
2965     checkout-index -u  |     |  checkout-index\r
2966              stat      |     |  blob obj\r
2967                              V\r
2968                     +-----------+\r
2969                     |  Working  |\r
2970                     | Directory |\r
2971                     +-----------+</literallayout>\r
2972 </section>\r
2973 </section>\r
2974 <section id="Git User Manual_examining-the-data">\r
2975 <title>Examining the data</title>\r
2976 <simpara>You can examine the data represented in the object database and the\r
2977 index with various helper tools. For every object, you can use\r
2978 <xref linkend="git-cat-file(1)" /> to examine details about the\r
2979 object:</simpara>\r
2980 <literallayout>$ git cat-file -t &lt;objectname&gt;</literallayout>\r
2981 <simpara>shows the type of the object, and once you have the type (which is\r
2982 usually implicit in where you find the object), you can use</simpara>\r
2983 <literallayout>$ git cat-file blob|tree|commit|tag &lt;objectname&gt;</literallayout>\r
2984 <simpara>to show its contents. NOTE! Trees have binary content, and as a result\r
2985 there is a special helper for showing that content, called\r
2986 <emphasis>git ls-tree</emphasis>, which turns the binary content into a more easily\r
2987 readable form.</simpara>\r
2988 <simpara>It's especially instructive to look at "commit" objects, since those\r
2989 tend to be small and fairly self-explanatory. In particular, if you\r
2990 follow the convention of having the top commit name in <emphasis>.git/HEAD</emphasis>,\r
2991 you can do</simpara>\r
2992 <literallayout>$ git cat-file commit HEAD</literallayout>\r
2993 <simpara>to see what the top commit was.</simpara>\r
2994 </section>\r
2995 <section id="Git User Manual_merging-multiple-trees">\r
2996 <title>Merging multiple trees</title>\r
2997 <simpara>Git can help you perform a three-way merge, which can in turn be\r
2998 used for a many-way merge by repeating the merge procedure several\r
2999 times.  The usual situation is that you only do one three-way merge\r
3000 (reconciling two lines of history) and commit the result, but if\r
3001 you like to, you can merge several branches in one go.</simpara>\r
3002 <simpara>To perform a three-way merge, you start with the two commits you\r
3003 want to merge, find their closest common parent (a third commit),\r
3004 and compare the trees corresponding to these three commits.</simpara>\r
3005 <simpara>To get the "base" for the merge, look up the common parent of two\r
3006 commits:</simpara>\r
3007 <literallayout>$ git merge-base &lt;commit1&gt; &lt;commit2&gt;</literallayout>\r
3008 <simpara>This prints the name of a commit they are both based on. You should\r
3009 now look up the tree objects of those commits, which you can easily\r
3010 do with</simpara>\r
3011 <literallayout>$ git cat-file commit &lt;commitname&gt; | head -1</literallayout>\r
3012 <simpara>since the tree object information is always the first line in a commit\r
3013 object.</simpara>\r
3014 <simpara>Once you know the three trees you are going to merge (the one "original"\r
3015 tree, aka the common tree, and the two "result" trees, aka the branches\r
3016 you want to merge), you do a "merge" read into the index. This will\r
3017 complain if it has to throw away your old index contents, so you should\r
3018 make sure that you've committed those--in fact you would normally\r
3019 always do a merge against your last commit (which should thus match what\r
3020 you have in your current index anyway).</simpara>\r
3021 <simpara>To do the merge, do</simpara>\r
3022 <literallayout>$ git read-tree -m -u &lt;origtree&gt; &lt;yourtree&gt; &lt;targettree&gt;</literallayout>\r
3023 <simpara>which will do all trivial merge operations for you directly in the\r
3024 index file, and you can just write the result out with\r
3025 <emphasis>git write-tree</emphasis>.</simpara>\r
3026 </section>\r
3027 <section id="Git User Manual_merging-multiple-trees-2">\r
3028 <title>Merging multiple trees, continued</title>\r
3029 <simpara>Sadly, many merges aren't trivial. If there are files that have\r
3030 been added, moved or removed, or if both branches have modified the\r
3031 same file, you will be left with an index tree that contains "merge\r
3032 entries" in it. Such an index tree can <emphasis>NOT</emphasis> be written out to a tree\r
3033 object, and you will have to resolve any such merge clashes using\r
3034 other tools before you can write out the result.</simpara>\r
3035 <simpara>You can examine such index state with <emphasis>git ls-files --unmerged</emphasis>\r
3036 command.  An example:</simpara>\r
3037 <literallayout>$ git read-tree -m $orig HEAD $target\r
3038 $ git ls-files --unmerged\r
3039 100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1       hello.c\r
3040 100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2       hello.c\r
3041 100644 cc44c73eb783565da5831b4d820c962954019b69 3       hello.c</literallayout>\r
3042 <simpara>Each line of the <emphasis>git ls-files --unmerged</emphasis> output begins with\r
3043 the blob mode bits, blob SHA-1, <emphasis>stage number</emphasis>, and the\r
3044 filename.  The <emphasis>stage number</emphasis> is Git's way to say which tree it\r
3045 came from: stage 1 corresponds to the <emphasis>$orig</emphasis> tree, stage 2 to\r
3046 the <emphasis>HEAD</emphasis> tree, and stage 3 to the <emphasis>$target</emphasis> tree.</simpara>\r
3047 <simpara>Earlier we said that trivial merges are done inside\r
3048 <emphasis>git read-tree -m</emphasis>.  For example, if the file did not change\r
3049 from <emphasis>$orig</emphasis> to <emphasis>HEAD</emphasis> or <emphasis>$target</emphasis>, or if the file changed\r
3050 from <emphasis>$orig</emphasis> to <emphasis>HEAD</emphasis> and <emphasis>$orig</emphasis> to <emphasis>$target</emphasis> the same way,\r
3051 obviously the final outcome is what is in <emphasis>HEAD</emphasis>.  What the\r
3052 above example shows is that file <emphasis>hello.c</emphasis> was changed from\r
3053 <emphasis>$orig</emphasis> to <emphasis>HEAD</emphasis> and <emphasis>$orig</emphasis> to <emphasis>$target</emphasis> in a different way.\r
3054 You could resolve this by running your favorite 3-way merge\r
3055 program, e.g.  <emphasis>diff3</emphasis>, <emphasis>merge</emphasis>, or Git's own merge-file, on\r
3056 the blob objects from these three stages yourself, like this:</simpara>\r
3057 <literallayout>$ git cat-file blob 263414f... &gt;hello.c~1\r
3058 $ git cat-file blob 06fa6a2... &gt;hello.c~2\r
3059 $ git cat-file blob cc44c73... &gt;hello.c~3\r
3060 $ git merge-file hello.c~2 hello.c~1 hello.c~3</literallayout>\r
3061 <simpara>This would leave the merge result in <emphasis>hello.c~2</emphasis> file, along\r
3062 with conflict markers if there are conflicts.  After verifying\r
3063 the merge result makes sense, you can tell Git what the final\r
3064 merge result for this file is by:</simpara>\r
3065 <literallayout>$ mv -f hello.c~2 hello.c\r
3066 $ git update-index hello.c</literallayout>\r
3067 <simpara>When a path is in the "unmerged" state, running <emphasis>git update-index</emphasis> for\r
3068 that path tells Git to mark the path resolved.</simpara>\r
3069 <simpara>The above is the description of a Git merge at the lowest level,\r
3070 to help you understand what conceptually happens under the hood.\r
3071 In practice, nobody, not even Git itself, runs <emphasis>git cat-file</emphasis> three times\r
3072 for this.  There is a <emphasis>git merge-index</emphasis> program that extracts the\r
3073 stages to temporary files and calls a "merge" script on it:</simpara>\r
3074 <literallayout>$ git merge-index git-merge-one-file hello.c</literallayout>\r
3075 <simpara>and that is what higher level <emphasis>git merge -s resolve</emphasis> is implemented with.</simpara>\r
3076 </section>\r
3077 </section>\r
3078 <section id="Git User Manual_hacking-git">\r
3079 <title>Hacking Git</title>\r
3080 <simpara>This chapter covers internal details of the Git implementation which\r
3081 probably only Git developers need to understand.</simpara>\r
3082 <section id="Git User Manual_object-details">\r
3083 <title>Object storage format</title>\r
3084 <simpara>All objects have a statically determined "type" which identifies the\r
3085 format of the object (i.e. how it is used, and how it can refer to other\r
3086 objects).  There are currently four different object types: "blob",\r
3087 "tree", "commit", and "tag".</simpara>\r
3088 <simpara>Regardless of object type, all objects share the following\r
3089 characteristics: they are all deflated with zlib, and have a header\r
3090 that not only specifies their type, but also provides size information\r
3091 about the data in the object.  It's worth noting that the SHA-1 hash\r
3092 that is used to name the object is the hash of the original data\r
3093 plus this header, so <emphasis>sha1sum</emphasis> <emphasis>file</emphasis> does not match the object name\r
3094 for <emphasis>file</emphasis>.</simpara>\r
3095 <simpara>As a result, the general consistency of an object can always be tested\r
3096 independently of the contents or the type of the object: all objects can\r
3097 be validated by verifying that (a) their hashes match the content of the\r
3098 file and (b) the object successfully inflates to a stream of bytes that\r
3099 forms a sequence of\r
3100 <emphasis>&lt;ascii type without space&gt; + &lt;space&gt; + &lt;ascii decimal size&gt; +\r
3101 &lt;byte\0&gt; + &lt;binary object data&gt;</emphasis>.</simpara>\r
3102 <simpara>The structured objects can further have their structure and\r
3103 connectivity to other objects verified. This is generally done with\r
3104 the <emphasis>git fsck</emphasis> program, which generates a full dependency graph\r
3105 of all objects, and verifies their internal consistency (in addition\r
3106 to just verifying their superficial consistency through the hash).</simpara>\r
3107 </section>\r
3108 <section id="Git User Manual_birdview-on-the-source-code">\r
3109 <title>A birds-eye view of Git's source code</title>\r
3110 <simpara>It is not always easy for new developers to find their way through Git's\r
3111 source code.  This section gives you a little guidance to show where to\r
3112 start.</simpara>\r
3113 <simpara>A good place to start is with the contents of the initial commit, with:</simpara>\r
3114 <literallayout>$ git checkout e83c5163</literallayout>\r
3115 <simpara>The initial revision lays the foundation for almost everything Git has\r
3116 today, but is small enough to read in one sitting.</simpara>\r
3117 <simpara>Note that terminology has changed since that revision.  For example, the\r
3118 README in that revision uses the word "changeset" to describe what we\r
3119 now call a <link linkend="Git User Manual_def_commit_object">commit</link>.</simpara>\r
3120 <simpara>Also, we do not call it "cache" any more, but rather "index"; however, the\r
3121 file is still called <emphasis>cache.h</emphasis>.  Remark: Not much reason to change it now,\r
3122 especially since there is no good single name for it anyway, because it is\r
3123 basically <emphasis>the</emphasis> header file which is included by <emphasis>all</emphasis> of Git's C sources.</simpara>\r
3124 <simpara>If you grasp the ideas in that initial commit, you should check out a\r
3125 more recent version and skim <emphasis>cache.h</emphasis>, <emphasis>object.h</emphasis> and <emphasis>commit.h</emphasis>.</simpara>\r
3126 <simpara>In the early days, Git (in the tradition of UNIX) was a bunch of programs\r
3127 which were extremely simple, and which you used in scripts, piping the\r
3128 output of one into another. This turned out to be good for initial\r
3129 development, since it was easier to test new things.  However, recently\r
3130 many of these parts have become builtins, and some of the core has been\r
3131 "libified", i.e. put into libgit.a for performance, portability reasons,\r
3132 and to avoid code duplication.</simpara>\r
3133 <simpara>By now, you know what the index is (and find the corresponding data\r
3134 structures in <emphasis>cache.h</emphasis>), and that there are just a couple of object types\r
3135 (blobs, trees, commits and tags) which inherit their common structure from\r
3136 <emphasis>struct object</emphasis>, which is their first member (and thus, you can cast e.g.\r
3137 <emphasis>(struct object *)commit</emphasis> to achieve the <emphasis>same</emphasis> as <emphasis>&amp;commit-&gt;object</emphasis>, i.e.\r
3138 get at the object name and flags).</simpara>\r
3139 <simpara>Now is a good point to take a break to let this information sink in.</simpara>\r
3140 <simpara>Next step: get familiar with the object naming.  Read <xref linkend="Git User Manual_naming-commits"/>.\r
3141 There are quite a few ways to name an object (and not only revisions!).\r
3142 All of these are handled in <emphasis>sha1_name.c</emphasis>. Just have a quick look at\r
3143 the function <emphasis>get_sha1()</emphasis>. A lot of the special handling is done by\r
3144 functions like <emphasis>get_sha1_basic()</emphasis> or the likes.</simpara>\r
3145 <simpara>This is just to get you into the groove for the most libified part of Git:\r
3146 the revision walker.</simpara>\r
3147 <simpara>Basically, the initial version of <emphasis>git log</emphasis> was a shell script:</simpara>\r
3148 <literallayout>$ git-rev-list --pretty $(git-rev-parse --default HEAD "$@") | \\r
3149         LESS=-S ${PAGER:-less}</literallayout>\r
3150 <simpara>What does this mean?</simpara>\r
3151 <simpara><emphasis>git rev-list</emphasis> is the original version of the revision walker, which\r
3152 <emphasis>always</emphasis> printed a list of revisions to stdout.  It is still functional,\r
3153 and needs to, since most new Git commands start out as scripts using\r
3154 <emphasis>git rev-list</emphasis>.</simpara>\r
3155 <simpara><emphasis>git rev-parse</emphasis> is not as important any more; it was only used to filter out\r
3156 options that were relevant for the different plumbing commands that were\r
3157 called by the script.</simpara>\r
3158 <simpara>Most of what <emphasis>git rev-list</emphasis> did is contained in <emphasis>revision.c</emphasis> and\r
3159 <emphasis>revision.h</emphasis>.  It wraps the options in a struct named <emphasis>rev_info</emphasis>, which\r
3160 controls how and what revisions are walked, and more.</simpara>\r
3161 <simpara>The original job of <emphasis>git rev-parse</emphasis> is now taken by the function\r
3162 <emphasis>setup_revisions()</emphasis>, which parses the revisions and the common command-line\r
3163 options for the revision walker. This information is stored in the struct\r
3164 <emphasis>rev_info</emphasis> for later consumption. You can do your own command-line option\r
3165 parsing after calling <emphasis>setup_revisions()</emphasis>. After that, you have to call\r
3166 <emphasis>prepare_revision_walk()</emphasis> for initialization, and then you can get the\r
3167 commits one by one with the function <emphasis>get_revision()</emphasis>.</simpara>\r
3168 <simpara>If you are interested in more details of the revision walking process,\r
3169 just have a look at the first implementation of <emphasis>cmd_log()</emphasis>; call\r
3170 <emphasis>git show v1.3.0~155^2~4</emphasis> and scroll down to that function (note that you\r
3171 no longer need to call <emphasis>setup_pager()</emphasis> directly).</simpara>\r
3172 <simpara>Nowadays, <emphasis>git log</emphasis> is a builtin, which means that it is <emphasis>contained</emphasis> in the\r
3173 command <emphasis>git</emphasis>.  The source side of a builtin is</simpara>\r
3174 <itemizedlist>\r
3175 <listitem>\r
3176 <simpara>\r
3177 a function called <emphasis>cmd_&lt;bla&gt;</emphasis>, typically defined in <emphasis>builtin/&lt;bla.c&gt;</emphasis>\r
3178   (note that older versions of Git used to have it in <emphasis>builtin-&lt;bla&gt;.c</emphasis>\r
3179   instead), and declared in <emphasis>builtin.h</emphasis>.\r
3180 </simpara>\r
3181 </listitem>\r
3182 <listitem>\r
3183 <simpara>\r
3184 an entry in the <emphasis>commands[]</emphasis> array in <emphasis>git.c</emphasis>, and\r
3185 </simpara>\r
3186 </listitem>\r
3187 <listitem>\r
3188 <simpara>\r
3189 an entry in <emphasis>BUILTIN_OBJECTS</emphasis> in the <emphasis>Makefile</emphasis>.\r
3190 </simpara>\r
3191 </listitem>\r
3192 </itemizedlist>\r
3193 <simpara>Sometimes, more than one builtin is contained in one source file.  For\r
3194 example, <emphasis>cmd_whatchanged()</emphasis> and <emphasis>cmd_log()</emphasis> both reside in <emphasis>builtin/log.c</emphasis>,\r
3195 since they share quite a bit of code.  In that case, the commands which are\r
3196 <emphasis>not</emphasis> named like the <emphasis>.c</emphasis> file in which they live have to be listed in\r
3197 <emphasis>BUILT_INS</emphasis> in the <emphasis>Makefile</emphasis>.</simpara>\r
3198 <simpara><emphasis>git log</emphasis> looks more complicated in C than it does in the original script,\r
3199 but that allows for a much greater flexibility and performance.</simpara>\r
3200 <simpara>Here again it is a good point to take a pause.</simpara>\r
3201 <simpara>Lesson three is: study the code.  Really, it is the best way to learn about\r
3202 the organization of Git (after you know the basic concepts).</simpara>\r
3203 <simpara>So, think about something which you are interested in, say, "how can I\r
3204 access a blob just knowing the object name of it?".  The first step is to\r
3205 find a Git command with which you can do it.  In this example, it is either\r
3206 <emphasis>git show</emphasis> or <emphasis>git cat-file</emphasis>.</simpara>\r
3207 <simpara>For the sake of clarity, let's stay with <emphasis>git cat-file</emphasis>, because it</simpara>\r
3208 <itemizedlist>\r
3209 <listitem>\r
3210 <simpara>\r
3211 is plumbing, and\r
3212 </simpara>\r
3213 </listitem>\r
3214 <listitem>\r
3215 <simpara>\r
3216 was around even in the initial commit (it literally went only through\r
3217   some 20 revisions as <emphasis>cat-file.c</emphasis>, was renamed to <emphasis>builtin/cat-file.c</emphasis>\r
3218   when made a builtin, and then saw less than 10 versions).\r
3219 </simpara>\r
3220 </listitem>\r
3221 </itemizedlist>\r
3222 <simpara>So, look into <emphasis>builtin/cat-file.c</emphasis>, search for <emphasis>cmd_cat_file()</emphasis> and look what\r
3223 it does.</simpara>\r
3224 <literallayout>        git_config(git_default_config);\r
3225         if (argc != 3)\r
3226                 usage("git cat-file [-t|-s|-e|-p|&lt;type&gt;] &lt;sha1&gt;");\r
3227         if (get_sha1(argv[2], sha1))\r
3228                 die("Not a valid object name %s", argv[2]);</literallayout>\r
3229 <simpara>Let's skip over the obvious details; the only really interesting part\r
3230 here is the call to <emphasis>get_sha1()</emphasis>.  It tries to interpret <emphasis>argv[2]</emphasis> as an\r
3231 object name, and if it refers to an object which is present in the current\r
3232 repository, it writes the resulting SHA-1 into the variable <emphasis>sha1</emphasis>.</simpara>\r
3233 <simpara>Two things are interesting here:</simpara>\r
3234 <itemizedlist>\r
3235 <listitem>\r
3236 <simpara>\r
3237 <emphasis>get_sha1()</emphasis> returns 0 on <emphasis>success</emphasis>.  This might surprise some new\r
3238   Git hackers, but there is a long tradition in UNIX to return different\r
3239   negative numbers in case of different errors--and 0 on success.\r
3240 </simpara>\r
3241 </listitem>\r
3242 <listitem>\r
3243 <simpara>\r
3244 the variable <emphasis>sha1</emphasis> in the function signature of <emphasis>get_sha1()</emphasis> is <emphasis>unsigned\r
3245   char *</emphasis>, but is actually expected to be a pointer to <emphasis>unsigned\r
3246   char[20]</emphasis>.  This variable will contain the 160-bit SHA-1 of the given\r
3247   commit.  Note that whenever a SHA-1 is passed as <emphasis>unsigned char *</emphasis>, it\r
3248   is the binary representation, as opposed to the ASCII representation in\r
3249   hex characters, which is passed as <emphasis>char *</emphasis>.\r
3250 </simpara>\r
3251 </listitem>\r
3252 </itemizedlist>\r
3253 <simpara>You will see both of these things throughout the code.</simpara>\r
3254 <simpara>Now, for the meat:</simpara>\r
3255 <literallayout>        case 0:\r
3256                 buf = read_object_with_reference(sha1, argv[1], &amp;size, NULL);</literallayout>\r
3257 <simpara>This is how you read a blob (actually, not only a blob, but any type of\r
3258 object).  To know how the function <emphasis>read_object_with_reference()</emphasis> actually\r
3259 works, find the source code for it (something like <emphasis>git grep\r
3260 read_object_with | grep ":[a-z]"</emphasis> in the Git repository), and read\r
3261 the source.</simpara>\r
3262 <simpara>To find out how the result can be used, just read on in <emphasis>cmd_cat_file()</emphasis>:</simpara>\r
3263 <literallayout>        write_or_die(1, buf, size);</literallayout>\r
3264 <simpara>Sometimes, you do not know where to look for a feature.  In many such cases,\r
3265 it helps to search through the output of <emphasis>git log</emphasis>, and then <emphasis>git show</emphasis> the\r
3266 corresponding commit.</simpara>\r
3267 <simpara>Example: If you know that there was some test case for <emphasis>git bundle</emphasis>, but\r
3268 do not remember where it was (yes, you <emphasis>could</emphasis> <emphasis>git grep bundle t/</emphasis>, but that\r
3269 does not illustrate the point!):</simpara>\r
3270 <literallayout>$ git log --no-merges t/</literallayout>\r
3271 <simpara>In the pager (<emphasis>less</emphasis>), just search for "bundle", go a few lines back,\r
3272 and see that it is in commit 18449ab0&#8230;  Now just copy this object name,\r
3273 and paste it into the command line</simpara>\r
3274 <literallayout>$ git show 18449ab0</literallayout>\r
3275 <simpara>Voila.</simpara>\r
3276 <simpara>Another example: Find out what to do in order to make some script a\r
3277 builtin:</simpara>\r
3278 <literallayout>$ git log --no-merges --diff-filter=A builtin/*.c</literallayout>\r
3279 <simpara>You see, Git is actually the best tool to find out about the source of Git\r
3280 itself!</simpara>\r
3281 </section>\r
3282 </section>\r
3283 <section id="Git User Manual_glossary">\r
3284 <title>Git Glossary</title>\r
3285 <variablelist>\r
3286 <varlistentry>\r
3287 <term>\r
3288 <anchor id="Git User Manual_def_alternate_object_database" xreflabel="[def_alternate_object_database]"/>alternate object database\r
3289 </term>\r
3290 <listitem>\r
3291 <simpara>\r
3292         Via the alternates mechanism, a <link linkend="Git User Manual_def_repository">repository</link>\r
3293         can inherit part of its <link linkend="Git User Manual_def_object_database">object database</link>\r
3294         from another object database, which is called an "alternate".\r
3295 </simpara>\r
3296 </listitem>\r
3297 </varlistentry>\r
3298 <varlistentry>\r
3299 <term>\r
3300 <anchor id="Git User Manual_def_bare_repository" xreflabel="[def_bare_repository]"/>bare repository\r
3301 </term>\r
3302 <listitem>\r
3303 <simpara>\r
3304         A bare repository is normally an appropriately\r
3305         named <link linkend="Git User Manual_def_directory">directory</link> with a <emphasis>.git</emphasis> suffix that does not\r
3306         have a locally checked-out copy of any of the files under\r
3307         revision control. That is, all of the Git\r
3308         administrative and control files that would normally be present in the\r
3309         hidden <emphasis>.git</emphasis> sub-directory are directly present in the\r
3310         <emphasis>repository.git</emphasis> directory instead,\r
3311         and no other files are present and checked out. Usually publishers of\r
3312         public repositories make bare repositories available.\r
3313 </simpara>\r
3314 </listitem>\r
3315 </varlistentry>\r
3316 <varlistentry>\r
3317 <term>\r
3318 <anchor id="Git User Manual_def_blob_object" xreflabel="[def_blob_object]"/>blob object\r
3319 </term>\r
3320 <listitem>\r
3321 <simpara>\r
3322         Untyped <link linkend="Git User Manual_def_object">object</link>, e.g. the contents of a file.\r
3323 </simpara>\r
3324 </listitem>\r
3325 </varlistentry>\r
3326 <varlistentry>\r
3327 <term>\r
3328 <anchor id="Git User Manual_def_branch" xreflabel="[def_branch]"/>branch\r
3329 </term>\r
3330 <listitem>\r
3331 <simpara>\r
3332         A "branch" is an active line of development.  The most recent\r
3333         <link linkend="Git User Manual_def_commit">commit</link> on a branch is referred to as the tip of\r
3334         that branch.  The tip of the branch is referenced by a branch\r
3335         <link linkend="Git User Manual_def_head">head</link>, which moves forward as additional development\r
3336         is done on the branch.  A single Git\r
3337         <link linkend="Git User Manual_def_repository">repository</link> can track an arbitrary number of\r
3338         branches, but your <link linkend="Git User Manual_def_working_tree">working tree</link> is\r
3339         associated with just one of them (the "current" or "checked out"\r
3340         branch), and <link linkend="Git User Manual_def_HEAD">HEAD</link> points to that branch.\r
3341 </simpara>\r
3342 </listitem>\r
3343 </varlistentry>\r
3344 <varlistentry>\r
3345 <term>\r
3346 <anchor id="Git User Manual_def_cache" xreflabel="[def_cache]"/>cache\r
3347 </term>\r
3348 <listitem>\r
3349 <simpara>\r
3350         Obsolete for: <link linkend="Git User Manual_def_index">index</link>.\r
3351 </simpara>\r
3352 </listitem>\r
3353 </varlistentry>\r
3354 <varlistentry>\r
3355 <term>\r
3356 <anchor id="Git User Manual_def_chain" xreflabel="[def_chain]"/>chain\r
3357 </term>\r
3358 <listitem>\r
3359 <simpara>\r
3360         A list of objects, where each <link linkend="Git User Manual_def_object">object</link> in the list contains\r
3361         a reference to its successor (for example, the successor of a\r
3362         <link linkend="Git User Manual_def_commit">commit</link> could be one of its <link linkend="Git User Manual_def_parent">parents</link>).\r
3363 </simpara>\r
3364 </listitem>\r
3365 </varlistentry>\r
3366 <varlistentry>\r
3367 <term>\r
3368 <anchor id="Git User Manual_def_changeset" xreflabel="[def_changeset]"/>changeset\r
3369 </term>\r
3370 <listitem>\r
3371 <simpara>\r
3372         BitKeeper/cvsps speak for "<link linkend="Git User Manual_def_commit">commit</link>". Since Git does not\r
3373         store changes, but states, it really does not make sense to use the term\r
3374         "changesets" with Git.\r
3375 </simpara>\r
3376 </listitem>\r
3377 </varlistentry>\r
3378 <varlistentry>\r
3379 <term>\r
3380 <anchor id="Git User Manual_def_checkout" xreflabel="[def_checkout]"/>checkout\r
3381 </term>\r
3382 <listitem>\r
3383 <simpara>\r
3384         The action of updating all or part of the\r
3385         <link linkend="Git User Manual_def_working_tree">working tree</link> with a <link linkend="Git User Manual_def_tree_object">tree object</link>\r
3386         or <link linkend="Git User Manual_def_blob_object">blob</link> from the\r
3387         <link linkend="Git User Manual_def_object_database">object database</link>, and updating the\r
3388         <link linkend="Git User Manual_def_index">index</link> and <link linkend="Git User Manual_def_HEAD">HEAD</link> if the whole working tree has\r
3389         been pointed at a new <link linkend="Git User Manual_def_branch">branch</link>.\r
3390 </simpara>\r
3391 </listitem>\r
3392 </varlistentry>\r
3393 <varlistentry>\r
3394 <term>\r
3395 <anchor id="Git User Manual_def_cherry-picking" xreflabel="[def_cherry-picking]"/>cherry-picking\r
3396 </term>\r
3397 <listitem>\r
3398 <simpara>\r
3399         In <link linkend="Git User Manual_def_SCM">SCM</link> jargon, "cherry pick" means to choose a subset of\r
3400         changes out of a series of changes (typically commits) and record them\r
3401         as a new series of changes on top of a different codebase. In Git, this is\r
3402         performed by the "git cherry-pick" command to extract the change introduced\r
3403         by an existing <link linkend="Git User Manual_def_commit">commit</link> and to record it based on the tip\r
3404         of the current <link linkend="Git User Manual_def_branch">branch</link> as a new commit.\r
3405 </simpara>\r
3406 </listitem>\r
3407 </varlistentry>\r
3408 <varlistentry>\r
3409 <term>\r
3410 <anchor id="Git User Manual_def_clean" xreflabel="[def_clean]"/>clean\r
3411 </term>\r
3412 <listitem>\r
3413 <simpara>\r
3414         A <link linkend="Git User Manual_def_working_tree">working tree</link> is clean, if it\r
3415         corresponds to the <link linkend="Git User Manual_def_revision">revision</link> referenced by the current\r
3416         <link linkend="Git User Manual_def_head">head</link>. Also see "<link linkend="Git User Manual_def_dirty">dirty</link>".\r
3417 </simpara>\r
3418 </listitem>\r
3419 </varlistentry>\r
3420 <varlistentry>\r
3421 <term>\r
3422 <anchor id="Git User Manual_def_commit" xreflabel="[def_commit]"/>commit\r
3423 </term>\r
3424 <listitem>\r
3425 <simpara>\r
3426         As a noun: A single point in the\r
3427         Git history; the entire history of a project is represented as a\r
3428         set of interrelated commits.  The word "commit" is often\r
3429         used by Git in the same places other revision control systems\r
3430         use the words "revision" or "version".  Also used as a short\r
3431         hand for <link linkend="Git User Manual_def_commit_object">commit object</link>.\r
3432 </simpara>\r
3433 <simpara>As a verb: The action of storing a new snapshot of the project's\r
3434 state in the Git history, by creating a new commit representing the current\r
3435 state of the <link linkend="Git User Manual_def_index">index</link> and advancing <link linkend="Git User Manual_def_HEAD">HEAD</link>\r
3436 to point at the new commit.</simpara>\r
3437 </listitem>\r
3438 </varlistentry>\r
3439 <varlistentry>\r
3440 <term>\r
3441 <anchor id="Git User Manual_def_commit_object" xreflabel="[def_commit_object]"/>commit object\r
3442 </term>\r
3443 <listitem>\r
3444 <simpara>\r
3445         An <link linkend="Git User Manual_def_object">object</link> which contains the information about a\r
3446         particular <link linkend="Git User Manual_def_revision">revision</link>, such as <link linkend="Git User Manual_def_parent">parents</link>, committer,\r
3447         author, date and the <link linkend="Git User Manual_def_tree_object">tree object</link> which corresponds\r
3448         to the top <link linkend="Git User Manual_def_directory">directory</link> of the stored\r
3449         revision.\r
3450 </simpara>\r
3451 </listitem>\r
3452 </varlistentry>\r
3453 <varlistentry>\r
3454 <term>\r
3455 <anchor id="Git User Manual_def_commit-ish" xreflabel="[def_commit-ish]"/>commit-ish (also committish)\r
3456 </term>\r
3457 <listitem>\r
3458 <simpara>\r
3459         A <link linkend="Git User Manual_def_commit_object">commit object</link> or an\r
3460         <link linkend="Git User Manual_def_object">object</link> that can be recursively dereferenced to\r
3461         a commit object.\r
3462         The following are all commit-ishes:\r
3463         a commit object,\r
3464         a <link linkend="Git User Manual_def_tag_object">tag object</link> that points to a commit\r
3465         object,\r
3466         a tag object that points to a tag object that points to a\r
3467         commit object,\r
3468         etc.\r
3469 </simpara>\r
3470 </listitem>\r
3471 </varlistentry>\r
3472 <varlistentry>\r
3473 <term>\r
3474 <anchor id="Git User Manual_def_core_git" xreflabel="[def_core_git]"/>core Git\r
3475 </term>\r
3476 <listitem>\r
3477 <simpara>\r
3478         Fundamental data structures and utilities of Git. Exposes only limited\r
3479         source code management tools.\r
3480 </simpara>\r
3481 </listitem>\r
3482 </varlistentry>\r
3483 <varlistentry>\r
3484 <term>\r
3485 <anchor id="Git User Manual_def_DAG" xreflabel="[def_DAG]"/>DAG\r
3486 </term>\r
3487 <listitem>\r
3488 <simpara>\r
3489         Directed acyclic graph. The <link linkend="Git User Manual_def_commit_object">commit objects</link> form a\r
3490         directed acyclic graph, because they have parents (directed), and the\r
3491         graph of commit objects is acyclic (there is no <link linkend="Git User Manual_def_chain">chain</link>\r
3492         which begins and ends with the same <link linkend="Git User Manual_def_object">object</link>).\r
3493 </simpara>\r
3494 </listitem>\r
3495 </varlistentry>\r
3496 <varlistentry>\r
3497 <term>\r
3498 <anchor id="Git User Manual_def_dangling_object" xreflabel="[def_dangling_object]"/>dangling object\r
3499 </term>\r
3500 <listitem>\r
3501 <simpara>\r
3502         An <link linkend="Git User Manual_def_unreachable_object">unreachable object</link> which is not\r
3503         <link linkend="Git User Manual_def_reachable">reachable</link> even from other unreachable objects; a\r
3504         dangling object has no references to it from any\r
3505         reference or <link linkend="Git User Manual_def_object">object</link> in the <link linkend="Git User Manual_def_repository">repository</link>.\r
3506 </simpara>\r
3507 </listitem>\r
3508 </varlistentry>\r
3509 <varlistentry>\r
3510 <term>\r
3511 <anchor id="Git User Manual_def_detached_HEAD" xreflabel="[def_detached_HEAD]"/>detached HEAD\r
3512 </term>\r
3513 <listitem>\r
3514 <simpara>\r
3515         Normally the <link linkend="Git User Manual_def_HEAD">HEAD</link> stores the name of a\r
3516         <link linkend="Git User Manual_def_branch">branch</link>, and commands that operate on the\r
3517         history HEAD represents operate on the history leading to the\r
3518         tip of the branch the HEAD points at.  However, Git also\r
3519         allows you to <link linkend="Git User Manual_def_checkout">check out</link> an arbitrary\r
3520         <link linkend="Git User Manual_def_commit">commit</link> that isn't necessarily the tip of any\r
3521         particular branch.  The HEAD in such a state is called\r
3522         "detached".\r
3523 </simpara>\r
3524 <simpara>Note that commands that operate on the history of the current branch\r
3525 (e.g. <emphasis>git commit</emphasis> to build a new history on top of it) still work\r
3526 while the HEAD is detached. They update the HEAD to point at the tip\r
3527 of the updated history without affecting any branch.  Commands that\r
3528 update or inquire information <emphasis>about</emphasis> the current branch (e.g. <emphasis>git\r
3529 branch --set-upstream-to</emphasis> that sets what remote-tracking branch the\r
3530 current branch integrates with) obviously do not work, as there is no\r
3531 (real) current branch to ask about in this state.</simpara>\r
3532 </listitem>\r
3533 </varlistentry>\r
3534 <varlistentry>\r
3535 <term>\r
3536 <anchor id="Git User Manual_def_directory" xreflabel="[def_directory]"/>directory\r
3537 </term>\r
3538 <listitem>\r
3539 <simpara>\r
3540         The list you get with "ls" :-)\r
3541 </simpara>\r
3542 </listitem>\r
3543 </varlistentry>\r
3544 <varlistentry>\r
3545 <term>\r
3546 <anchor id="Git User Manual_def_dirty" xreflabel="[def_dirty]"/>dirty\r
3547 </term>\r
3548 <listitem>\r
3549 <simpara>\r
3550         A <link linkend="Git User Manual_def_working_tree">working tree</link> is said to be "dirty" if\r
3551         it contains modifications which have not been <link linkend="Git User Manual_def_commit">committed</link> to the current\r
3552         <link linkend="Git User Manual_def_branch">branch</link>.\r
3553 </simpara>\r
3554 </listitem>\r
3555 </varlistentry>\r
3556 <varlistentry>\r
3557 <term>\r
3558 <anchor id="Git User Manual_def_evil_merge" xreflabel="[def_evil_merge]"/>evil merge\r
3559 </term>\r
3560 <listitem>\r
3561 <simpara>\r
3562         An evil merge is a <link linkend="Git User Manual_def_merge">merge</link> that introduces changes that\r
3563         do not appear in any <link linkend="Git User Manual_def_parent">parent</link>.\r
3564 </simpara>\r
3565 </listitem>\r
3566 </varlistentry>\r
3567 <varlistentry>\r
3568 <term>\r
3569 <anchor id="Git User Manual_def_fast_forward" xreflabel="[def_fast_forward]"/>fast-forward\r
3570 </term>\r
3571 <listitem>\r
3572 <simpara>\r
3573         A fast-forward is a special type of <link linkend="Git User Manual_def_merge">merge</link> where you have a\r
3574         <link linkend="Git User Manual_def_revision">revision</link> and you are "merging" another\r
3575         <link linkend="Git User Manual_def_branch">branch</link>'s changes that happen to be a descendant of what\r
3576         you have. In such these cases, you do not make a new <link linkend="Git User Manual_def_merge">merge</link>\r
3577         <link linkend="Git User Manual_def_commit">commit</link> but instead just update to his\r
3578         revision. This will happen frequently on a\r
3579         <link linkend="Git User Manual_def_remote_tracking_branch">remote-tracking branch</link> of a remote\r
3580         <link linkend="Git User Manual_def_repository">repository</link>.\r
3581 </simpara>\r
3582 </listitem>\r
3583 </varlistentry>\r
3584 <varlistentry>\r
3585 <term>\r
3586 <anchor id="Git User Manual_def_fetch" xreflabel="[def_fetch]"/>fetch\r
3587 </term>\r
3588 <listitem>\r
3589 <simpara>\r
3590         Fetching a <link linkend="Git User Manual_def_branch">branch</link> means to get the\r
3591         branch's <link linkend="Git User Manual_def_head_ref">head ref</link> from a remote\r
3592         <link linkend="Git User Manual_def_repository">repository</link>, to find out which objects are\r
3593         missing from the local <link linkend="Git User Manual_def_object_database">object database</link>,\r
3594         and to get them, too.  See also <xref linkend="git-fetch(1)" />.\r
3595 </simpara>\r
3596 </listitem>\r
3597 </varlistentry>\r
3598 <varlistentry>\r
3599 <term>\r
3600 <anchor id="Git User Manual_def_file_system" xreflabel="[def_file_system]"/>file system\r
3601 </term>\r
3602 <listitem>\r
3603 <simpara>\r
3604         Linus Torvalds originally designed Git to be a user space file system,\r
3605         i.e. the infrastructure to hold files and directories. That ensured the\r
3606         efficiency and speed of Git.\r
3607 </simpara>\r
3608 </listitem>\r
3609 </varlistentry>\r
3610 <varlistentry>\r
3611 <term>\r
3612 <anchor id="Git User Manual_def_git_archive" xreflabel="[def_git_archive]"/>Git archive\r
3613 </term>\r
3614 <listitem>\r
3615 <simpara>\r
3616         Synonym for <link linkend="Git User Manual_def_repository">repository</link> (for arch people).\r
3617 </simpara>\r
3618 </listitem>\r
3619 </varlistentry>\r
3620 <varlistentry>\r
3621 <term>\r
3622 <anchor id="Git User Manual_def_gitfile" xreflabel="[def_gitfile]"/>gitfile\r
3623 </term>\r
3624 <listitem>\r
3625 <simpara>\r
3626         A plain file <emphasis>.git</emphasis> at the root of a working tree that\r
3627         points at the directory that is the real repository.\r
3628 </simpara>\r
3629 </listitem>\r
3630 </varlistentry>\r
3631 <varlistentry>\r
3632 <term>\r
3633 <anchor id="Git User Manual_def_grafts" xreflabel="[def_grafts]"/>grafts\r
3634 </term>\r
3635 <listitem>\r
3636 <simpara>\r
3637         Grafts enables two otherwise different lines of development to be joined\r
3638         together by recording fake ancestry information for commits. This way\r
3639         you can make Git pretend the set of <link linkend="Git User Manual_def_parent">parents</link> a <link linkend="Git User Manual_def_commit">commit</link> has\r
3640         is different from what was recorded when the commit was\r
3641         created. Configured via the <emphasis>.git/info/grafts</emphasis> file.\r
3642 </simpara>\r
3643 <simpara>Note that the grafts mechanism is outdated and can lead to problems\r
3644 transferring objects between repositories; see <xref linkend="git-replace(1)" />\r
3645 for a more flexible and robust system to do the same thing.</simpara>\r
3646 </listitem>\r
3647 </varlistentry>\r
3648 <varlistentry>\r
3649 <term>\r
3650 <anchor id="Git User Manual_def_hash" xreflabel="[def_hash]"/>hash\r
3651 </term>\r
3652 <listitem>\r
3653 <simpara>\r
3654         In Git's context, synonym for <link linkend="Git User Manual_def_object_name">object name</link>.\r
3655 </simpara>\r
3656 </listitem>\r
3657 </varlistentry>\r
3658 <varlistentry>\r
3659 <term>\r
3660 <anchor id="Git User Manual_def_head" xreflabel="[def_head]"/>head\r
3661 </term>\r
3662 <listitem>\r
3663 <simpara>\r
3664         A <link linkend="Git User Manual_def_ref">named reference</link> to the <link linkend="Git User Manual_def_commit">commit</link> at the tip of a\r
3665         <link linkend="Git User Manual_def_branch">branch</link>.  Heads are stored in a file in\r
3666         <emphasis>$GIT_DIR/refs/heads/</emphasis> directory, except when using packed refs. (See\r
3667         <xref linkend="git-pack-refs(1)" />.)\r
3668 </simpara>\r
3669 </listitem>\r
3670 </varlistentry>\r
3671 <varlistentry>\r
3672 <term>\r
3673 <anchor id="Git User Manual_def_HEAD" xreflabel="[def_HEAD]"/>HEAD\r
3674 </term>\r
3675 <listitem>\r
3676 <simpara>\r
3677         The current <link linkend="Git User Manual_def_branch">branch</link>.  In more detail: Your <link linkend="Git User Manual_def_working_tree">working tree</link> is normally derived from the state of the tree\r
3678         referred to by HEAD.  HEAD is a reference to one of the\r
3679         <link linkend="Git User Manual_def_head">heads</link> in your repository, except when using a\r
3680         <link linkend="Git User Manual_def_detached_HEAD">detached HEAD</link>, in which case it directly\r
3681         references an arbitrary commit.\r
3682 </simpara>\r
3683 </listitem>\r
3684 </varlistentry>\r
3685 <varlistentry>\r
3686 <term>\r
3687 <anchor id="Git User Manual_def_head_ref" xreflabel="[def_head_ref]"/>head ref\r
3688 </term>\r
3689 <listitem>\r
3690 <simpara>\r
3691         A synonym for <link linkend="Git User Manual_def_head">head</link>.\r
3692 </simpara>\r
3693 </listitem>\r
3694 </varlistentry>\r
3695 <varlistentry>\r
3696 <term>\r
3697 <anchor id="Git User Manual_def_hook" xreflabel="[def_hook]"/>hook\r
3698 </term>\r
3699 <listitem>\r
3700 <simpara>\r
3701         During the normal execution of several Git commands, call-outs are made\r
3702         to optional scripts that allow a developer to add functionality or\r
3703         checking. Typically, the hooks allow for a command to be pre-verified\r
3704         and potentially aborted, and allow for a post-notification after the\r
3705         operation is done. The hook scripts are found in the\r
3706         <emphasis>$GIT_DIR/hooks/</emphasis> directory, and are enabled by simply\r
3707         removing the <emphasis>.sample</emphasis> suffix from the filename. In earlier versions\r
3708         of Git you had to make them executable.\r
3709 </simpara>\r
3710 </listitem>\r
3711 </varlistentry>\r
3712 <varlistentry>\r
3713 <term>\r
3714 <anchor id="Git User Manual_def_index" xreflabel="[def_index]"/>index\r
3715 </term>\r
3716 <listitem>\r
3717 <simpara>\r
3718         A collection of files with stat information, whose contents are stored\r
3719         as objects. The index is a stored version of your\r
3720         <link linkend="Git User Manual_def_working_tree">working tree</link>. Truth be told, it can also contain a second, and even\r
3721         a third version of a working tree, which are used\r
3722         when <link linkend="Git User Manual_def_merge">merging</link>.\r
3723 </simpara>\r
3724 </listitem>\r
3725 </varlistentry>\r
3726 <varlistentry>\r
3727 <term>\r
3728 <anchor id="Git User Manual_def_index_entry" xreflabel="[def_index_entry]"/>index entry\r
3729 </term>\r
3730 <listitem>\r
3731 <simpara>\r
3732         The information regarding a particular file, stored in the\r
3733         <link linkend="Git User Manual_def_index">index</link>. An index entry can be unmerged, if a\r
3734         <link linkend="Git User Manual_def_merge">merge</link> was started, but not yet finished (i.e. if\r
3735         the index contains multiple versions of that file).\r
3736 </simpara>\r
3737 </listitem>\r
3738 </varlistentry>\r
3739 <varlistentry>\r
3740 <term>\r
3741 <anchor id="Git User Manual_def_master" xreflabel="[def_master]"/>master\r
3742 </term>\r
3743 <listitem>\r
3744 <simpara>\r
3745         The default development <link linkend="Git User Manual_def_branch">branch</link>. Whenever you\r
3746         create a Git <link linkend="Git User Manual_def_repository">repository</link>, a branch named\r
3747         "master" is created, and becomes the active branch. In most\r
3748         cases, this contains the local development, though that is\r
3749         purely by convention and is not required.\r
3750 </simpara>\r
3751 </listitem>\r
3752 </varlistentry>\r
3753 <varlistentry>\r
3754 <term>\r
3755 <anchor id="Git User Manual_def_merge" xreflabel="[def_merge]"/>merge\r
3756 </term>\r
3757 <listitem>\r
3758 <simpara>\r
3759         As a verb: To bring the contents of another\r
3760         <link linkend="Git User Manual_def_branch">branch</link> (possibly from an external\r
3761         <link linkend="Git User Manual_def_repository">repository</link>) into the current branch.  In the\r
3762         case where the merged-in branch is from a different repository,\r
3763         this is done by first <link linkend="Git User Manual_def_fetch">fetching</link> the remote branch\r
3764         and then merging the result into the current branch.  This\r
3765         combination of fetch and merge operations is called a\r
3766         <link linkend="Git User Manual_def_pull">pull</link>.  Merging is performed by an automatic process\r
3767         that identifies changes made since the branches diverged, and\r
3768         then applies all those changes together.  In cases where changes\r
3769         conflict, manual intervention may be required to complete the\r
3770         merge.\r
3771 </simpara>\r
3772 <simpara>As a noun: unless it is a <link linkend="Git User Manual_def_fast_forward">fast-forward</link>, a\r
3773 successful merge results in the creation of a new <link linkend="Git User Manual_def_commit">commit</link>\r
3774 representing the result of the merge, and having as\r
3775 <link linkend="Git User Manual_def_parent">parents</link> the tips of the merged <link linkend="Git User Manual_def_branch">branches</link>.\r
3776 This commit is referred to as a "merge commit", or sometimes just a\r
3777 "merge".</simpara>\r
3778 </listitem>\r
3779 </varlistentry>\r
3780 <varlistentry>\r
3781 <term>\r
3782 <anchor id="Git User Manual_def_object" xreflabel="[def_object]"/>object\r
3783 </term>\r
3784 <listitem>\r
3785 <simpara>\r
3786         The unit of storage in Git. It is uniquely identified by the\r
3787         <link linkend="Git User Manual_def_SHA1">SHA-1</link> of its contents. Consequently, an\r
3788         object can not be changed.\r
3789 </simpara>\r
3790 </listitem>\r
3791 </varlistentry>\r
3792 <varlistentry>\r
3793 <term>\r
3794 <anchor id="Git User Manual_def_object_database" xreflabel="[def_object_database]"/>object database\r
3795 </term>\r
3796 <listitem>\r
3797 <simpara>\r
3798         Stores a set of "objects", and an individual <link linkend="Git User Manual_def_object">object</link> is\r
3799         identified by its <link linkend="Git User Manual_def_object_name">object name</link>. The objects usually\r
3800         live in <emphasis>$GIT_DIR/objects/</emphasis>.\r
3801 </simpara>\r
3802 </listitem>\r
3803 </varlistentry>\r
3804 <varlistentry>\r
3805 <term>\r
3806 <anchor id="Git User Manual_def_object_identifier" xreflabel="[def_object_identifier]"/>object identifier\r
3807 </term>\r
3808 <listitem>\r
3809 <simpara>\r
3810         Synonym for <link linkend="Git User Manual_def_object_name">object name</link>.\r
3811 </simpara>\r
3812 </listitem>\r
3813 </varlistentry>\r
3814 <varlistentry>\r
3815 <term>\r
3816 <anchor id="Git User Manual_def_object_name" xreflabel="[def_object_name]"/>object name\r
3817 </term>\r
3818 <listitem>\r
3819 <simpara>\r
3820         The unique identifier of an <link linkend="Git User Manual_def_object">object</link>.  The\r
3821         object name is usually represented by a 40 character\r
3822         hexadecimal string.  Also colloquially called <link linkend="Git User Manual_def_SHA1">SHA-1</link>.\r
3823 </simpara>\r
3824 </listitem>\r
3825 </varlistentry>\r
3826 <varlistentry>\r
3827 <term>\r
3828 <anchor id="Git User Manual_def_object_type" xreflabel="[def_object_type]"/>object type\r
3829 </term>\r
3830 <listitem>\r
3831 <simpara>\r
3832         One of the identifiers "<link linkend="Git User Manual_def_commit_object">commit</link>",\r
3833         "<link linkend="Git User Manual_def_tree_object">tree</link>", "<link linkend="Git User Manual_def_tag_object">tag</link>" or\r
3834         "<link linkend="Git User Manual_def_blob_object">blob</link>" describing the type of an\r
3835         <link linkend="Git User Manual_def_object">object</link>.\r
3836 </simpara>\r
3837 </listitem>\r
3838 </varlistentry>\r
3839 <varlistentry>\r
3840 <term>\r
3841 <anchor id="Git User Manual_def_octopus" xreflabel="[def_octopus]"/>octopus\r
3842 </term>\r
3843 <listitem>\r
3844 <simpara>\r
3845         To <link linkend="Git User Manual_def_merge">merge</link> more than two <link linkend="Git User Manual_def_branch">branches</link>.\r
3846 </simpara>\r
3847 </listitem>\r
3848 </varlistentry>\r
3849 <varlistentry>\r
3850 <term>\r
3851 <anchor id="Git User Manual_def_origin" xreflabel="[def_origin]"/>origin\r
3852 </term>\r
3853 <listitem>\r
3854 <simpara>\r
3855         The default upstream <link linkend="Git User Manual_def_repository">repository</link>. Most projects have\r
3856         at least one upstream project which they track. By default\r
3857         <emphasis>origin</emphasis> is used for that purpose. New upstream updates\r
3858         will be fetched into <link linkend="Git User Manual_def_remote_tracking_branch">remote-tracking branches</link> named\r
3859         origin/name-of-upstream-branch, which you can see using\r
3860         <emphasis>git branch -r</emphasis>.\r
3861 </simpara>\r
3862 </listitem>\r
3863 </varlistentry>\r
3864 <varlistentry>\r
3865 <term>\r
3866 <anchor id="Git User Manual_def_pack" xreflabel="[def_pack]"/>pack\r
3867 </term>\r
3868 <listitem>\r
3869 <simpara>\r
3870         A set of objects which have been compressed into one file (to save space\r
3871         or to transmit them efficiently).\r
3872 </simpara>\r
3873 </listitem>\r
3874 </varlistentry>\r
3875 <varlistentry>\r
3876 <term>\r
3877 <anchor id="Git User Manual_def_pack_index" xreflabel="[def_pack_index]"/>pack index\r
3878 </term>\r
3879 <listitem>\r
3880 <simpara>\r
3881         The list of identifiers, and other information, of the objects in a\r
3882         <link linkend="Git User Manual_def_pack">pack</link>, to assist in efficiently accessing the contents of a\r
3883         pack.\r
3884 </simpara>\r
3885 </listitem>\r
3886 </varlistentry>\r
3887 <varlistentry>\r
3888 <term>\r
3889 <anchor id="Git User Manual_def_pathspec" xreflabel="[def_pathspec]"/>pathspec\r
3890 </term>\r
3891 <listitem>\r
3892 <simpara>\r
3893         Pattern used to limit paths in Git commands.\r
3894 </simpara>\r
3895 <simpara>Pathspecs are used on the command line of "git ls-files", "git\r
3896 ls-tree", "git add", "git grep", "git diff", "git checkout",\r
3897 and many other commands to\r
3898 limit the scope of operations to some subset of the tree or\r
3899 worktree.  See the documentation of each command for whether\r
3900 paths are relative to the current directory or toplevel.  The\r
3901 pathspec syntax is as follows:</simpara>\r
3902 <itemizedlist>\r
3903 <listitem>\r
3904 <simpara>\r
3905 any path matches itself\r
3906 </simpara>\r
3907 </listitem>\r
3908 <listitem>\r
3909 <simpara>\r
3910 the pathspec up to the last slash represents a\r
3911   directory prefix.  The scope of that pathspec is\r
3912   limited to that subtree.\r
3913 </simpara>\r
3914 </listitem>\r
3915 <listitem>\r
3916 <simpara>\r
3917 the rest of the pathspec is a pattern for the remainder\r
3918   of the pathname.  Paths relative to the directory\r
3919   prefix will be matched against that pattern using fnmatch(3);\r
3920   in particular, <emphasis>*</emphasis> and <emphasis>?</emphasis> <emphasis>can</emphasis> match directory separators.\r
3921 </simpara>\r
3922 </listitem>\r
3923 </itemizedlist>\r
3924 <simpara>For example, Documentation/*.jpg will match all .jpg files\r
3925 in the Documentation subtree,\r
3926 including Documentation/chapter_1/figure_1.jpg.</simpara>\r
3927 <simpara>A pathspec that begins with a colon <emphasis>:</emphasis> has special meaning.  In the\r
3928 short form, the leading colon <emphasis>:</emphasis> is followed by zero or more "magic\r
3929 signature" letters (which optionally is terminated by another colon <emphasis>:</emphasis>),\r
3930 and the remainder is the pattern to match against the path.\r
3931 The "magic signature" consists of ASCII symbols that are neither\r
3932 alphanumeric, glob, regex special characters nor colon.\r
3933 The optional colon that terminates the "magic signature" can be\r
3934 omitted if the pattern begins with a character that does not belong to\r
3935 "magic signature" symbol set and is not a colon.</simpara>\r
3936 <simpara>In the long form, the leading colon <emphasis>:</emphasis> is followed by a open\r
3937 parenthesis <emphasis>(</emphasis>, a comma-separated list of zero or more "magic words",\r
3938 and a close parentheses <emphasis>)</emphasis>, and the remainder is the pattern to match\r
3939 against the path.</simpara>\r
3940 <simpara>A pathspec with only a colon means "there is no pathspec". This form\r
3941 should not be combined with other pathspec.</simpara>\r
3942 <variablelist>\r
3943 <varlistentry>\r
3944 <term>\r
3945 top\r
3946 </term>\r
3947 <listitem>\r
3948 <simpara>\r
3949         The magic word <emphasis>top</emphasis> (magic signature: <emphasis>/</emphasis>) makes the pattern\r
3950         match from the root of the working tree, even when you are\r
3951         running the command from inside a subdirectory.\r
3952 </simpara>\r
3953 </listitem>\r
3954 </varlistentry>\r
3955 <varlistentry>\r
3956 <term>\r
3957 literal\r
3958 </term>\r
3959 <listitem>\r
3960 <simpara>\r
3961         Wildcards in the pattern such as <emphasis>*</emphasis> or <emphasis>?</emphasis> are treated\r
3962         as literal characters.\r
3963 </simpara>\r
3964 </listitem>\r
3965 </varlistentry>\r
3966 <varlistentry>\r
3967 <term>\r
3968 icase\r
3969 </term>\r
3970 <listitem>\r
3971 <simpara>\r
3972         Case insensitive match.\r
3973 </simpara>\r
3974 </listitem>\r
3975 </varlistentry>\r
3976 <varlistentry>\r
3977 <term>\r
3978 glob\r
3979 </term>\r
3980 <listitem>\r
3981 <simpara>\r
3982         Git treats the pattern as a shell glob suitable for\r
3983         consumption by fnmatch(3) with the FNM_PATHNAME flag:\r
3984         wildcards in the pattern will not match a / in the pathname.\r
3985         For example, "Documentation/&#42;.html" matches\r
3986         "Documentation/git.html" but not "Documentation/ppc/ppc.html"\r
3987         or "tools/perf/Documentation/perf.html".\r
3988 </simpara>\r
3989 <simpara>Two consecutive asterisks ("<emphasis>**</emphasis>") in patterns matched against\r
3990 full pathname may have special meaning:</simpara>\r
3991 <itemizedlist>\r
3992 <listitem>\r
3993 <simpara>\r
3994 A leading "<emphasis>**</emphasis>" followed by a slash means match in all\r
3995    directories. For example, "<emphasis>**/foo</emphasis>" matches file or directory\r
3996    "<emphasis>foo</emphasis>" anywhere, the same as pattern "<emphasis>foo</emphasis>". "<emphasis>**/foo/bar</emphasis>"\r
3997    matches file or directory "<emphasis>bar</emphasis>" anywhere that is directly\r
3998    under directory "<emphasis>foo</emphasis>".\r
3999 </simpara>\r
4000 </listitem>\r
4001 <listitem>\r
4002 <simpara>\r
4003 A trailing "<emphasis>/**</emphasis>" matches everything inside. For example,\r
4004    "<emphasis>abc/**</emphasis>" matches all files inside directory "abc", relative\r
4005    to the location of the <emphasis>.gitignore</emphasis> file, with infinite depth.\r
4006 </simpara>\r
4007 </listitem>\r
4008 <listitem>\r
4009 <simpara>\r
4010 A slash followed by two consecutive asterisks then a slash\r
4011    matches zero or more directories. For example, "<emphasis>a/**/b</emphasis>"\r
4012    matches "<emphasis>a/b</emphasis>", "<emphasis>a/x/b</emphasis>", "<emphasis>a/x/y/b</emphasis>" and so on.\r
4013 </simpara>\r
4014 </listitem>\r
4015 <listitem>\r
4016 <simpara>\r
4017 Other consecutive asterisks are considered invalid.\r
4018 </simpara>\r
4019 <simpara>Glob magic is incompatible with literal magic.</simpara>\r
4020 </listitem>\r
4021 </itemizedlist>\r
4022 </listitem>\r
4023 </varlistentry>\r
4024 <varlistentry>\r
4025 <term>\r
4026 exclude\r
4027 </term>\r
4028 <listitem>\r
4029 <simpara>\r
4030         After a path matches any non-exclude pathspec, it will be run\r
4031         through all exclude pathspec (magic signature: <emphasis>!</emphasis>). If it\r
4032         matches, the path is ignored.\r
4033 </simpara>\r
4034 </listitem>\r
4035 </varlistentry>\r
4036 </variablelist>\r
4037 </listitem>\r
4038 </varlistentry>\r
4039 <varlistentry>\r
4040 <term>\r
4041 <anchor id="Git User Manual_def_parent" xreflabel="[def_parent]"/>parent\r
4042 </term>\r
4043 <listitem>\r
4044 <simpara>\r
4045         A <link linkend="Git User Manual_def_commit_object">commit object</link> contains a (possibly empty) list\r
4046         of the logical predecessor(s) in the line of development, i.e. its\r
4047         parents.\r
4048 </simpara>\r
4049 </listitem>\r
4050 </varlistentry>\r
4051 <varlistentry>\r
4052 <term>\r
4053 <anchor id="Git User Manual_def_pickaxe" xreflabel="[def_pickaxe]"/>pickaxe\r
4054 </term>\r
4055 <listitem>\r
4056 <simpara>\r
4057         The term <link linkend="Git User Manual_def_pickaxe">pickaxe</link> refers to an option to the diffcore\r
4058         routines that help select changes that add or delete a given text\r
4059         string. With the <emphasis>--pickaxe-all</emphasis> option, it can be used to view the full\r
4060         <link linkend="Git User Manual_def_changeset">changeset</link> that introduced or removed, say, a\r
4061         particular line of text. See <xref linkend="git-diff(1)" />.\r
4062 </simpara>\r
4063 </listitem>\r
4064 </varlistentry>\r
4065 <varlistentry>\r
4066 <term>\r
4067 <anchor id="Git User Manual_def_plumbing" xreflabel="[def_plumbing]"/>plumbing\r
4068 </term>\r
4069 <listitem>\r
4070 <simpara>\r
4071         Cute name for <link linkend="Git User Manual_def_core_git">core Git</link>.\r
4072 </simpara>\r
4073 </listitem>\r
4074 </varlistentry>\r
4075 <varlistentry>\r
4076 <term>\r
4077 <anchor id="Git User Manual_def_porcelain" xreflabel="[def_porcelain]"/>porcelain\r
4078 </term>\r
4079 <listitem>\r
4080 <simpara>\r
4081         Cute name for programs and program suites depending on\r
4082         <link linkend="Git User Manual_def_core_git">core Git</link>, presenting a high level access to\r
4083         core Git. Porcelains expose more of a <link linkend="Git User Manual_def_SCM">SCM</link>\r
4084         interface than the <link linkend="Git User Manual_def_plumbing">plumbing</link>.\r
4085 </simpara>\r
4086 </listitem>\r
4087 </varlistentry>\r
4088 <varlistentry>\r
4089 <term>\r
4090 <anchor id="Git User Manual_def_per_worktree_ref" xreflabel="[def_per_worktree_ref]"/>per-worktree ref\r
4091 </term>\r
4092 <listitem>\r
4093 <simpara>\r
4094         Refs that are per-<link linkend="Git User Manual_def_working_tree">worktree</link>, rather than\r
4095         global.  This is presently only <link linkend="Git User Manual_def_HEAD">HEAD</link> and any refs\r
4096         that start with <emphasis>refs/bisect/</emphasis>, but might later include other\r
4097         unusual refs.\r
4098 </simpara>\r
4099 </listitem>\r
4100 </varlistentry>\r
4101 <varlistentry>\r
4102 <term>\r
4103 <anchor id="Git User Manual_def_pseudoref" xreflabel="[def_pseudoref]"/>pseudoref\r
4104 </term>\r
4105 <listitem>\r
4106 <simpara>\r
4107         Pseudorefs are a class of files under <emphasis>$GIT_DIR</emphasis> which behave\r
4108         like refs for the purposes of rev-parse, but which are treated\r
4109         specially by git.  Pseudorefs both have names that are all-caps,\r
4110         and always start with a line consisting of a\r
4111         <link linkend="Git User Manual_def_SHA1">SHA-1</link> followed by whitespace.  So, HEAD is not a\r
4112         pseudoref, because it is sometimes a symbolic ref.  They might\r
4113         optionally contain some additional data.  <emphasis>MERGE_HEAD</emphasis> and\r
4114         <emphasis>CHERRY_PICK_HEAD</emphasis> are examples.  Unlike\r
4115         <link linkend="Git User Manual_def_per_worktree_ref">per-worktree refs</link>, these files cannot\r
4116         be symbolic refs, and never have reflogs.  They also cannot be\r
4117         updated through the normal ref update machinery.  Instead,\r
4118         they are updated by directly writing to the files.  However,\r
4119         they can be read as if they were refs, so <emphasis>git rev-parse\r
4120         MERGE_HEAD</emphasis> will work.\r
4121 </simpara>\r
4122 </listitem>\r
4123 </varlistentry>\r
4124 <varlistentry>\r
4125 <term>\r
4126 <anchor id="Git User Manual_def_pull" xreflabel="[def_pull]"/>pull\r
4127 </term>\r
4128 <listitem>\r
4129 <simpara>\r
4130         Pulling a <link linkend="Git User Manual_def_branch">branch</link> means to <link linkend="Git User Manual_def_fetch">fetch</link> it and\r
4131         <link linkend="Git User Manual_def_merge">merge</link> it.  See also <xref linkend="git-pull(1)" />.\r
4132 </simpara>\r
4133 </listitem>\r
4134 </varlistentry>\r
4135 <varlistentry>\r
4136 <term>\r
4137 <anchor id="Git User Manual_def_push" xreflabel="[def_push]"/>push\r
4138 </term>\r
4139 <listitem>\r
4140 <simpara>\r
4141         Pushing a <link linkend="Git User Manual_def_branch">branch</link> means to get the branch's\r
4142         <link linkend="Git User Manual_def_head_ref">head ref</link> from a remote <link linkend="Git User Manual_def_repository">repository</link>,\r
4143         find out if it is a direct ancestor to the branch's local\r
4144         head ref, and in that case, putting all\r
4145         objects, which are <link linkend="Git User Manual_def_reachable">reachable</link> from the local\r
4146         head ref, and which are missing from the remote\r
4147         repository, into the remote\r
4148         <link linkend="Git User Manual_def_object_database">object database</link>, and updating the remote\r
4149         head ref. If the remote <link linkend="Git User Manual_def_head">head</link> is not an\r
4150         ancestor to the local head, the push fails.\r
4151 </simpara>\r
4152 </listitem>\r
4153 </varlistentry>\r
4154 <varlistentry>\r
4155 <term>\r
4156 <anchor id="Git User Manual_def_reachable" xreflabel="[def_reachable]"/>reachable\r
4157 </term>\r
4158 <listitem>\r
4159 <simpara>\r
4160         All of the ancestors of a given <link linkend="Git User Manual_def_commit">commit</link> are said to be\r
4161         "reachable" from that commit. More\r
4162         generally, one <link linkend="Git User Manual_def_object">object</link> is reachable from\r
4163         another if we can reach the one from the other by a <link linkend="Git User Manual_def_chain">chain</link>\r
4164         that follows <link linkend="Git User Manual_def_tag">tags</link> to whatever they tag,\r
4165         <link linkend="Git User Manual_def_commit_object">commits</link> to their parents or trees, and\r
4166         <link linkend="Git User Manual_def_tree_object">trees</link> to the trees or <link linkend="Git User Manual_def_blob_object">blobs</link>\r
4167         that they contain.\r
4168 </simpara>\r
4169 </listitem>\r
4170 </varlistentry>\r
4171 <varlistentry>\r
4172 <term>\r
4173 <anchor id="Git User Manual_def_rebase" xreflabel="[def_rebase]"/>rebase\r
4174 </term>\r
4175 <listitem>\r
4176 <simpara>\r
4177         To reapply a series of changes from a <link linkend="Git User Manual_def_branch">branch</link> to a\r
4178         different base, and reset the <link linkend="Git User Manual_def_head">head</link> of that branch\r
4179         to the result.\r
4180 </simpara>\r
4181 </listitem>\r
4182 </varlistentry>\r
4183 <varlistentry>\r
4184 <term>\r
4185 <anchor id="Git User Manual_def_ref" xreflabel="[def_ref]"/>ref\r
4186 </term>\r
4187 <listitem>\r
4188 <simpara>\r
4189         A name that begins with <emphasis>refs/</emphasis> (e.g. <emphasis>refs/heads/master</emphasis>)\r
4190         that points to an <link linkend="Git User Manual_def_object_name">object name</link> or another\r
4191         ref (the latter is called a <link linkend="Git User Manual_def_symref">symbolic ref</link>).\r
4192         For convenience, a ref can sometimes be abbreviated when used\r
4193         as an argument to a Git command; see <xref linkend="gitrevisions(7)" />\r
4194         for details.\r
4195         Refs are stored in the <link linkend="Git User Manual_def_repository">repository</link>.\r
4196 </simpara>\r
4197 <simpara>The ref namespace is hierarchical.\r
4198 Different subhierarchies are used for different purposes (e.g. the\r
4199 <emphasis>refs/heads/</emphasis> hierarchy is used to represent local branches).</simpara>\r
4200 <simpara>There are a few special-purpose refs that do not begin with <emphasis>refs/</emphasis>.\r
4201 The most notable example is <emphasis>HEAD</emphasis>.</simpara>\r
4202 </listitem>\r
4203 </varlistentry>\r
4204 <varlistentry>\r
4205 <term>\r
4206 <anchor id="Git User Manual_def_reflog" xreflabel="[def_reflog]"/>reflog\r
4207 </term>\r
4208 <listitem>\r
4209 <simpara>\r
4210         A reflog shows the local "history" of a ref.  In other words,\r
4211         it can tell you what the 3rd last revision in <emphasis>this</emphasis> repository\r
4212         was, and what was the current state in <emphasis>this</emphasis> repository,\r
4213         yesterday 9:14pm.  See <xref linkend="git-reflog(1)" /> for details.\r
4214 </simpara>\r
4215 </listitem>\r
4216 </varlistentry>\r
4217 <varlistentry>\r
4218 <term>\r
4219 <anchor id="Git User Manual_def_refspec" xreflabel="[def_refspec]"/>refspec\r
4220 </term>\r
4221 <listitem>\r
4222 <simpara>\r
4223         A "refspec" is used by <link linkend="Git User Manual_def_fetch">fetch</link> and\r
4224         <link linkend="Git User Manual_def_push">push</link> to describe the mapping between remote\r
4225         <link linkend="Git User Manual_def_ref">ref</link> and local ref.\r
4226 </simpara>\r
4227 </listitem>\r
4228 </varlistentry>\r
4229 <varlistentry>\r
4230 <term>\r
4231 <anchor id="Git User Manual_def_remote" xreflabel="[def_remote]"/>remote repository\r
4232 </term>\r
4233 <listitem>\r
4234 <simpara>\r
4235         A <link linkend="Git User Manual_def_repository">repository</link> which is used to track the same\r
4236         project but resides somewhere else. To communicate with remotes,\r
4237         see <link linkend="Git User Manual_def_fetch">fetch</link> or <link linkend="Git User Manual_def_push">push</link>.\r
4238 </simpara>\r
4239 </listitem>\r
4240 </varlistentry>\r
4241 <varlistentry>\r
4242 <term>\r
4243 <anchor id="Git User Manual_def_remote_tracking_branch" xreflabel="[def_remote_tracking_branch]"/>remote-tracking branch\r
4244 </term>\r
4245 <listitem>\r
4246 <simpara>\r
4247         A <link linkend="Git User Manual_def_ref">ref</link> that is used to follow changes from another\r
4248         <link linkend="Git User Manual_def_repository">repository</link>. It typically looks like\r
4249         <emphasis>refs/remotes/foo/bar</emphasis> (indicating that it tracks a branch named\r
4250         <emphasis>bar</emphasis> in a remote named <emphasis>foo</emphasis>), and matches the right-hand-side of\r
4251         a configured fetch <link linkend="Git User Manual_def_refspec">refspec</link>. A remote-tracking\r
4252         branch should not contain direct modifications or have local\r
4253         commits made to it.\r
4254 </simpara>\r
4255 </listitem>\r
4256 </varlistentry>\r
4257 <varlistentry>\r
4258 <term>\r
4259 <anchor id="Git User Manual_def_repository" xreflabel="[def_repository]"/>repository\r
4260 </term>\r
4261 <listitem>\r
4262 <simpara>\r
4263         A collection of <link linkend="Git User Manual_def_ref">refs</link> together with an\r
4264         <link linkend="Git User Manual_def_object_database">object database</link> containing all objects\r
4265         which are <link linkend="Git User Manual_def_reachable">reachable</link> from the refs, possibly\r
4266         accompanied by meta data from one or more <link linkend="Git User Manual_def_porcelain">porcelains</link>. A\r
4267         repository can share an object database with other repositories\r
4268         via <link linkend="Git User Manual_def_alternate_object_database">alternates mechanism</link>.\r
4269 </simpara>\r
4270 </listitem>\r
4271 </varlistentry>\r
4272 <varlistentry>\r
4273 <term>\r
4274 <anchor id="Git User Manual_def_resolve" xreflabel="[def_resolve]"/>resolve\r
4275 </term>\r
4276 <listitem>\r
4277 <simpara>\r
4278         The action of fixing up manually what a failed automatic\r
4279         <link linkend="Git User Manual_def_merge">merge</link> left behind.\r
4280 </simpara>\r
4281 </listitem>\r
4282 </varlistentry>\r
4283 <varlistentry>\r
4284 <term>\r
4285 <anchor id="Git User Manual_def_revision" xreflabel="[def_revision]"/>revision\r
4286 </term>\r
4287 <listitem>\r
4288 <simpara>\r
4289         Synonym for <link linkend="Git User Manual_def_commit">commit</link> (the noun).\r
4290 </simpara>\r
4291 </listitem>\r
4292 </varlistentry>\r
4293 <varlistentry>\r
4294 <term>\r
4295 <anchor id="Git User Manual_def_rewind" xreflabel="[def_rewind]"/>rewind\r
4296 </term>\r
4297 <listitem>\r
4298 <simpara>\r
4299         To throw away part of the development, i.e. to assign the\r
4300         <link linkend="Git User Manual_def_head">head</link> to an earlier <link linkend="Git User Manual_def_revision">revision</link>.\r
4301 </simpara>\r
4302 </listitem>\r
4303 </varlistentry>\r
4304 <varlistentry>\r
4305 <term>\r
4306 <anchor id="Git User Manual_def_SCM" xreflabel="[def_SCM]"/>SCM\r
4307 </term>\r
4308 <listitem>\r
4309 <simpara>\r
4310         Source code management (tool).\r
4311 </simpara>\r
4312 </listitem>\r
4313 </varlistentry>\r
4314 <varlistentry>\r
4315 <term>\r
4316 <anchor id="Git User Manual_def_SHA1" xreflabel="[def_SHA1]"/>SHA-1\r
4317 </term>\r
4318 <listitem>\r
4319 <simpara>\r
4320         "Secure Hash Algorithm 1"; a cryptographic hash function.\r
4321         In the context of Git used as a synonym for <link linkend="Git User Manual_def_object_name">object name</link>.\r
4322 </simpara>\r
4323 </listitem>\r
4324 </varlistentry>\r
4325 <varlistentry>\r
4326 <term>\r
4327 <anchor id="Git User Manual_def_shallow_clone" xreflabel="[def_shallow_clone]"/>shallow clone\r
4328 </term>\r
4329 <listitem>\r
4330 <simpara>\r
4331         Mostly a synonym to <link linkend="Git User Manual_def_shallow_repository">shallow repository</link>\r
4332         but the phrase makes it more explicit that it was created by\r
4333         running <emphasis>git clone --depth=...</emphasis> command.\r
4334 </simpara>\r
4335 </listitem>\r
4336 </varlistentry>\r
4337 <varlistentry>\r
4338 <term>\r
4339 <anchor id="Git User Manual_def_shallow_repository" xreflabel="[def_shallow_repository]"/>shallow repository\r
4340 </term>\r
4341 <listitem>\r
4342 <simpara>\r
4343         A shallow <link linkend="Git User Manual_def_repository">repository</link> has an incomplete\r
4344         history some of whose <link linkend="Git User Manual_def_commit">commits</link> have <link linkend="Git User Manual_def_parent">parents</link> cauterized away (in other\r
4345         words, Git is told to pretend that these commits do not have the\r
4346         parents, even though they are recorded in the <link linkend="Git User Manual_def_commit_object">commit         object</link>). This is sometimes useful when you are interested only in the\r
4347         recent history of a project even though the real history recorded in the\r
4348         upstream is much larger. A shallow repository\r
4349         is created by giving the <emphasis>--depth</emphasis> option to <xref linkend="git-clone(1)" />, and\r
4350         its history can be later deepened with <xref linkend="git-fetch(1)" />.\r
4351 </simpara>\r
4352 </listitem>\r
4353 </varlistentry>\r
4354 <varlistentry>\r
4355 <term>\r
4356 <anchor id="Git User Manual_def_submodule" xreflabel="[def_submodule]"/>submodule\r
4357 </term>\r
4358 <listitem>\r
4359 <simpara>\r
4360         A <link linkend="Git User Manual_def_repository">repository</link> that holds the history of a\r
4361         separate project inside another repository (the latter of\r
4362         which is called <link linkend="Git User Manual_def_superproject">superproject</link>).\r
4363 </simpara>\r
4364 </listitem>\r
4365 </varlistentry>\r
4366 <varlistentry>\r
4367 <term>\r
4368 <anchor id="Git User Manual_def_superproject" xreflabel="[def_superproject]"/>superproject\r
4369 </term>\r
4370 <listitem>\r
4371 <simpara>\r
4372         A <link linkend="Git User Manual_def_repository">repository</link> that references repositories\r
4373         of other projects in its working tree as <link linkend="Git User Manual_def_submodule">submodules</link>.\r
4374         The superproject knows about the names of (but does not hold\r
4375         copies of) commit objects of the contained submodules.\r
4376 </simpara>\r
4377 </listitem>\r
4378 </varlistentry>\r
4379 <varlistentry>\r
4380 <term>\r
4381 <anchor id="Git User Manual_def_symref" xreflabel="[def_symref]"/>symref\r
4382 </term>\r
4383 <listitem>\r
4384 <simpara>\r
4385         Symbolic reference: instead of containing the <link linkend="Git User Manual_def_SHA1">SHA-1</link>\r
4386         id itself, it is of the format <emphasis>ref: refs/some/thing</emphasis> and when\r
4387         referenced, it recursively dereferences to this reference.\r
4388         <emphasis><link linkend="Git User Manual_def_HEAD">HEAD</link></emphasis> is a prime example of a symref. Symbolic\r
4389         references are manipulated with the <xref linkend="git-symbolic-ref(1)" />\r
4390         command.\r
4391 </simpara>\r
4392 </listitem>\r
4393 </varlistentry>\r
4394 <varlistentry>\r
4395 <term>\r
4396 <anchor id="Git User Manual_def_tag" xreflabel="[def_tag]"/>tag\r
4397 </term>\r
4398 <listitem>\r
4399 <simpara>\r
4400         A <link linkend="Git User Manual_def_ref">ref</link> under <emphasis>refs/tags/</emphasis> namespace that points to an\r
4401         object of an arbitrary type (typically a tag points to either a\r
4402         <link linkend="Git User Manual_def_tag_object">tag</link> or a <link linkend="Git User Manual_def_commit_object">commit object</link>).\r
4403         In contrast to a <link linkend="Git User Manual_def_head">head</link>, a tag is not updated by\r
4404         the <emphasis>commit</emphasis> command. A Git tag has nothing to do with a Lisp\r
4405         tag (which would be called an <link linkend="Git User Manual_def_object_type">object type</link>\r
4406         in Git's context). A tag is most typically used to mark a particular\r
4407         point in the commit ancestry <link linkend="Git User Manual_def_chain">chain</link>.\r
4408 </simpara>\r
4409 </listitem>\r
4410 </varlistentry>\r
4411 <varlistentry>\r
4412 <term>\r
4413 <anchor id="Git User Manual_def_tag_object" xreflabel="[def_tag_object]"/>tag object\r
4414 </term>\r
4415 <listitem>\r
4416 <simpara>\r
4417         An <link linkend="Git User Manual_def_object">object</link> containing a <link linkend="Git User Manual_def_ref">ref</link> pointing to\r
4418         another object, which can contain a message just like a\r
4419         <link linkend="Git User Manual_def_commit_object">commit object</link>. It can also contain a (PGP)\r
4420         signature, in which case it is called a "signed tag object".\r
4421 </simpara>\r
4422 </listitem>\r
4423 </varlistentry>\r
4424 <varlistentry>\r
4425 <term>\r
4426 <anchor id="Git User Manual_def_topic_branch" xreflabel="[def_topic_branch]"/>topic branch\r
4427 </term>\r
4428 <listitem>\r
4429 <simpara>\r
4430         A regular Git <link linkend="Git User Manual_def_branch">branch</link> that is used by a developer to\r
4431         identify a conceptual line of development. Since branches are very easy\r
4432         and inexpensive, it is often desirable to have several small branches\r
4433         that each contain very well defined concepts or small incremental yet\r
4434         related changes.\r
4435 </simpara>\r
4436 </listitem>\r
4437 </varlistentry>\r
4438 <varlistentry>\r
4439 <term>\r
4440 <anchor id="Git User Manual_def_tree" xreflabel="[def_tree]"/>tree\r
4441 </term>\r
4442 <listitem>\r
4443 <simpara>\r
4444         Either a <link linkend="Git User Manual_def_working_tree">working tree</link>, or a <link linkend="Git User Manual_def_tree_object">tree         object</link> together with the dependent <link linkend="Git User Manual_def_blob_object">blob</link> and tree objects\r
4445         (i.e. a stored representation of a working tree).\r
4446 </simpara>\r
4447 </listitem>\r
4448 </varlistentry>\r
4449 <varlistentry>\r
4450 <term>\r
4451 <anchor id="Git User Manual_def_tree_object" xreflabel="[def_tree_object]"/>tree object\r
4452 </term>\r
4453 <listitem>\r
4454 <simpara>\r
4455         An <link linkend="Git User Manual_def_object">object</link> containing a list of file names and modes along\r
4456         with refs to the associated blob and/or tree objects. A\r
4457         <link linkend="Git User Manual_def_tree">tree</link> is equivalent to a <link linkend="Git User Manual_def_directory">directory</link>.\r
4458 </simpara>\r
4459 </listitem>\r
4460 </varlistentry>\r
4461 <varlistentry>\r
4462 <term>\r
4463 <anchor id="Git User Manual_def_tree-ish" xreflabel="[def_tree-ish]"/>tree-ish (also treeish)\r
4464 </term>\r
4465 <listitem>\r
4466 <simpara>\r
4467         A <link linkend="Git User Manual_def_tree_object">tree object</link> or an <link linkend="Git User Manual_def_object">object</link>\r
4468         that can be recursively dereferenced to a tree object.\r
4469         Dereferencing a <link linkend="Git User Manual_def_commit_object">commit object</link> yields the\r
4470         tree object corresponding to the <link linkend="Git User Manual_def_revision">revision</link>'s\r
4471         top <link linkend="Git User Manual_def_directory">directory</link>.\r
4472         The following are all tree-ishes:\r
4473         a <link linkend="Git User Manual_def_commit-ish">commit-ish</link>,\r
4474         a tree object,\r
4475         a <link linkend="Git User Manual_def_tag_object">tag object</link> that points to a tree object,\r
4476         a tag object that points to a tag object that points to a tree\r
4477         object,\r
4478         etc.\r
4479 </simpara>\r
4480 </listitem>\r
4481 </varlistentry>\r
4482 <varlistentry>\r
4483 <term>\r
4484 <anchor id="Git User Manual_def_unmerged_index" xreflabel="[def_unmerged_index]"/>unmerged index\r
4485 </term>\r
4486 <listitem>\r
4487 <simpara>\r
4488         An <link linkend="Git User Manual_def_index">index</link> which contains unmerged\r
4489         <link linkend="Git User Manual_def_index_entry">index entries</link>.\r
4490 </simpara>\r
4491 </listitem>\r
4492 </varlistentry>\r
4493 <varlistentry>\r
4494 <term>\r
4495 <anchor id="Git User Manual_def_unreachable_object" xreflabel="[def_unreachable_object]"/>unreachable object\r
4496 </term>\r
4497 <listitem>\r
4498 <simpara>\r
4499         An <link linkend="Git User Manual_def_object">object</link> which is not <link linkend="Git User Manual_def_reachable">reachable</link> from a\r
4500         <link linkend="Git User Manual_def_branch">branch</link>, <link linkend="Git User Manual_def_tag">tag</link>, or any other reference.\r
4501 </simpara>\r
4502 </listitem>\r
4503 </varlistentry>\r
4504 <varlistentry>\r
4505 <term>\r
4506 <anchor id="Git User Manual_def_upstream_branch" xreflabel="[def_upstream_branch]"/>upstream branch\r
4507 </term>\r
4508 <listitem>\r
4509 <simpara>\r
4510         The default <link linkend="Git User Manual_def_branch">branch</link> that is merged into the branch in\r
4511         question (or the branch in question is rebased onto). It is configured\r
4512         via branch.&lt;name&gt;.remote and branch.&lt;name&gt;.merge. If the upstream branch\r
4513         of <emphasis>A</emphasis> is <emphasis>origin/B</emphasis> sometimes we say "<emphasis>A</emphasis> is tracking <emphasis>origin/B</emphasis>".\r
4514 </simpara>\r
4515 </listitem>\r
4516 </varlistentry>\r
4517 <varlistentry>\r
4518 <term>\r
4519 <anchor id="Git User Manual_def_working_tree" xreflabel="[def_working_tree]"/>working tree\r
4520 </term>\r
4521 <listitem>\r
4522 <simpara>\r
4523         The tree of actual checked out files.  The working tree normally\r
4524         contains the contents of the <link linkend="Git User Manual_def_HEAD">HEAD</link> commit's tree,\r
4525         plus any local changes that you have made but not yet committed.\r
4526 </simpara>\r
4527 </listitem>\r
4528 </varlistentry>\r
4529 </variablelist>\r
4530 </section>\r
4531 <sect3 id="Git User Manual_git-quick-start">\r
4532 <title>Git Quick Reference</title>\r
4533 <simpara>This is a quick summary of the major commands; the previous chapters\r
4534 explain how these work in more detail.</simpara>\r
4535 <section id="Git User Manual_quick-creating-a-new-repository">\r
4536 <title>Creating a new repository</title>\r
4537 <simpara>From a tarball:</simpara>\r
4538 <literallayout>$ tar xzf project.tar.gz\r
4539 $ cd project\r
4540 $ git init\r
4541 Initialized empty Git repository in .git/\r
4542 $ git add .\r
4543 $ git commit</literallayout>\r
4544 <simpara>From a remote repository:</simpara>\r
4545 <literallayout>$ git clone git://example.com/pub/project.git\r
4546 $ cd project</literallayout>\r
4547 </section>\r
4548 <section id="Git User Manual_managing-branches">\r
4549 <title>Managing branches</title>\r
4550 <literallayout>$ git branch         # list all local branches in this repo\r
4551 $ git checkout test  # switch working directory to branch "test"\r
4552 $ git branch new     # create branch "new" starting at current HEAD\r
4553 $ git branch -d new  # delete branch "new"</literallayout>\r
4554 <simpara>Instead of basing a new branch on current HEAD (the default), use:</simpara>\r
4555 <literallayout>$ git branch new test    # branch named "test"\r
4556 $ git branch new v2.6.15 # tag named v2.6.15\r
4557 $ git branch new HEAD^   # commit before the most recent\r
4558 $ git branch new HEAD^^  # commit before that\r
4559 $ git branch new test~10 # ten commits before tip of branch "test"</literallayout>\r
4560 <simpara>Create and switch to a new branch at the same time:</simpara>\r
4561 <literallayout>$ git checkout -b new v2.6.15</literallayout>\r
4562 <simpara>Update and examine branches from the repository you cloned from:</simpara>\r
4563 <literallayout>$ git fetch             # update\r
4564 $ git branch -r         # list\r
4565   origin/master\r
4566   origin/next\r
4567   ...\r
4568 $ git checkout -b masterwork origin/master</literallayout>\r
4569 <simpara>Fetch a branch from a different repository, and give it a new\r
4570 name in your repository:</simpara>\r
4571 <literallayout>$ git fetch git://example.com/project.git theirbranch:mybranch\r
4572 $ git fetch git://example.com/project.git v2.6.15:mybranch</literallayout>\r
4573 <simpara>Keep a list of repositories you work with regularly:</simpara>\r
4574 <literallayout>$ git remote add example git://example.com/project.git\r
4575 $ git remote                    # list remote repositories\r
4576 example\r
4577 origin\r
4578 $ git remote show example       # get details\r
4579 * remote example\r
4580   URL: git://example.com/project.git\r
4581   Tracked remote branches\r
4582     master\r
4583     next\r
4584     ...\r
4585 $ git fetch example             # update branches from example\r
4586 $ git branch -r                 # list all remote branches</literallayout>\r
4587 </section>\r
4588 <section id="Git User Manual_exploring-history">\r
4589 <title>Exploring history</title>\r
4590 <literallayout>$ gitk                      # visualize and browse history\r
4591 $ git log                   # list all commits\r
4592 $ git log src/              # ...modifying src/\r
4593 $ git log v2.6.15..v2.6.16  # ...in v2.6.16, not in v2.6.15\r
4594 $ git log master..test      # ...in branch test, not in branch master\r
4595 $ git log test..master      # ...in branch master, but not in test\r
4596 $ git log test...master     # ...in one branch, not in both\r
4597 $ git log -S'foo()'         # ...where difference contain "foo()"\r
4598 $ git log --since="2 weeks ago"\r
4599 $ git log -p                # show patches as well\r
4600 $ git show                  # most recent commit\r
4601 $ git diff v2.6.15..v2.6.16 # diff between two tagged versions\r
4602 $ git diff v2.6.15..HEAD    # diff with current head\r
4603 $ git grep "foo()"          # search working directory for "foo()"\r
4604 $ git grep v2.6.15 "foo()"  # search old tree for "foo()"\r
4605 $ git show v2.6.15:a.txt    # look at old version of a.txt</literallayout>\r
4606 <simpara>Search for regressions:</simpara>\r
4607 <literallayout>$ git bisect start\r
4608 $ git bisect bad                # current version is bad\r
4609 $ git bisect good v2.6.13-rc2   # last known good revision\r
4610 Bisecting: 675 revisions left to test after this\r
4611                                 # test here, then:\r
4612 $ git bisect good               # if this revision is good, or\r
4613 $ git bisect bad                # if this revision is bad.\r
4614                                 # repeat until done.</literallayout>\r
4615 </section>\r
4616 <section id="Git User Manual_making-changes">\r
4617 <title>Making changes</title>\r
4618 <simpara>Make sure Git knows who to blame:</simpara>\r
4619 <literallayout>$ cat &gt;&gt;~/.gitconfig &lt;&lt;\EOF\r
4620 [user]\r
4621         name = Your Name Comes Here\r
4622         email = you@yourdomain.example.com\r
4623 EOF</literallayout>\r
4624 <simpara>Select file contents to include in the next commit, then make the\r
4625 commit:</simpara>\r
4626 <literallayout>$ git add a.txt    # updated file\r
4627 $ git add b.txt    # new file\r
4628 $ git rm c.txt     # old file\r
4629 $ git commit</literallayout>\r
4630 <simpara>Or, prepare and create the commit in one step:</simpara>\r
4631 <literallayout>$ git commit d.txt # use latest content only of d.txt\r
4632 $ git commit -a    # use latest content of all tracked files</literallayout>\r
4633 </section>\r
4634 <section id="Git User Manual_merging">\r
4635 <title>Merging</title>\r
4636 <literallayout>$ git merge test   # merge branch "test" into the current branch\r
4637 $ git pull git://example.com/project.git master\r
4638                    # fetch and merge in remote branch\r
4639 $ git pull . test  # equivalent to git merge test</literallayout>\r
4640 </section>\r
4641 <section id="Git User Manual_sharing-your-changes">\r
4642 <title>Sharing your changes</title>\r
4643 <simpara>Importing or exporting patches:</simpara>\r
4644 <literallayout>$ git format-patch origin..HEAD # format a patch for each commit\r
4645                                 # in HEAD but not in origin\r
4646 $ git am mbox # import patches from the mailbox "mbox"</literallayout>\r
4647 <simpara>Fetch a branch in a different Git repository, then merge into the\r
4648 current branch:</simpara>\r
4649 <literallayout>$ git pull git://example.com/project.git theirbranch</literallayout>\r
4650 <simpara>Store the fetched branch into a local branch before merging into the\r
4651 current branch:</simpara>\r
4652 <literallayout>$ git pull git://example.com/project.git theirbranch:mybranch</literallayout>\r
4653 <simpara>After creating commits on a local branch, update the remote\r
4654 branch with your commits:</simpara>\r
4655 <literallayout>$ git push ssh://example.com/project.git mybranch:theirbranch</literallayout>\r
4656 <simpara>When remote and local branch are both named "test":</simpara>\r
4657 <literallayout>$ git push ssh://example.com/project.git test</literallayout>\r
4658 <simpara>Shortcut version for a frequently used remote repository:</simpara>\r
4659 <literallayout>$ git remote add example ssh://example.com/project.git\r
4660 $ git push example test</literallayout>\r
4661 </section>\r
4662 <section id="Git User Manual_repository-maintenance">\r
4663 <title>Repository maintenance</title>\r
4664 <simpara>Check for corruption:</simpara>\r
4665 <literallayout>$ git fsck</literallayout>\r
4666 <simpara>Recompress, remove unused cruft:</simpara>\r
4667 <literallayout>$ git gc</literallayout>\r
4668 </section>\r
4669 </sect3>\r
4670 <sect3 id="Git User Manual_todo">\r
4671 <title>Notes and todo list for this manual</title>\r
4672 <simpara>This is a work in progress.</simpara>\r
4673 <simpara>The basic requirements:</simpara>\r
4674 <itemizedlist>\r
4675 <listitem>\r
4676 <simpara>\r
4677 It must be readable in order, from beginning to end, by someone\r
4678   intelligent with a basic grasp of the UNIX command line, but without\r
4679   any special knowledge of Git.  If necessary, any other prerequisites\r
4680   should be specifically mentioned as they arise.\r
4681 </simpara>\r
4682 </listitem>\r
4683 <listitem>\r
4684 <simpara>\r
4685 Whenever possible, section headings should clearly describe the task\r
4686   they explain how to do, in language that requires no more knowledge\r
4687   than necessary: for example, "importing patches into a project" rather\r
4688   than "the <emphasis>git am</emphasis> command"\r
4689 </simpara>\r
4690 </listitem>\r
4691 </itemizedlist>\r
4692 <simpara>Think about how to create a clear chapter dependency graph that will\r
4693 allow people to get to important topics without necessarily reading\r
4694 everything in between.</simpara>\r
4695 <simpara>Scan <emphasis>Documentation/</emphasis> for other stuff left out; in particular:</simpara>\r
4696 <itemizedlist>\r
4697 <listitem>\r
4698 <simpara>\r
4699 howto's\r
4700 </simpara>\r
4701 </listitem>\r
4702 <listitem>\r
4703 <simpara>\r
4704 some of <emphasis>technical/</emphasis>?\r
4705 </simpara>\r
4706 </listitem>\r
4707 <listitem>\r
4708 <simpara>\r
4709 hooks\r
4710 </simpara>\r
4711 </listitem>\r
4712 <listitem>\r
4713 <simpara>\r
4714 list of commands in <xref linkend="git(1)" />\r
4715 </simpara>\r
4716 </listitem>\r
4717 </itemizedlist>\r
4718 <simpara>Scan email archives for other stuff left out</simpara>\r
4719 <simpara>Scan man pages to see if any assume more background than this manual\r
4720 provides.</simpara>\r
4721 <simpara>Add more good examples.  Entire sections of just cookbook examples\r
4722 might be a good idea; maybe make an "advanced examples" section a\r
4723 standard end-of-chapter section?</simpara>\r
4724 <simpara>Include cross-references to the glossary, where appropriate.</simpara>\r
4725 <simpara>Add a section on working with other version control systems, including\r
4726 CVS, Subversion, and just imports of series of release tarballs.</simpara>\r
4727 <simpara>Write a chapter on using plumbing and writing scripts.</simpara>\r
4728 <simpara>Alternates, clone -reference, etc.</simpara>\r
4729 <simpara>More on recovery from repository corruption.  See:\r
4730         <ulink url="http://marc.info/?l=git&amp;m=117263864820799&amp;w=2">http://marc.info/?l=git&amp;m=117263864820799&amp;w=2</ulink>\r
4731         <ulink url="http://marc.info/?l=git&amp;m=117147855503798&amp;w=2">http://marc.info/?l=git&amp;m=117147855503798&amp;w=2</ulink></simpara>\r
4732 </sect3>\r
4733 </sect2>\r