Autogenerated HTML docs for v1.4.0-rc1-gfd7e
[git.git] / tutorial.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\r
2     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
3 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
4 <head>\r
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\r
6 <meta name="generator" content="AsciiDoc 7.0.2" />\r
7 <style type="text/css">\r
8 /* Debug borders */\r
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {\r
10 /*\r
11   border: 1px solid red;\r
12 */\r
13 }\r
14 \r
15 body {\r
16   margin: 1em 5% 1em 5%;\r
17 }\r
18 \r
19 a { color: blue; }\r
20 a:visited { color: fuchsia; }\r
21 \r
22 em {\r
23   font-style: italic;\r
24 }\r
25 \r
26 strong {\r
27   font-weight: bold;\r
28 }\r
29 \r
30 tt {\r
31   color: navy;\r
32 }\r
33 \r
34 h1, h2, h3, h4, h5, h6 {\r
35   color: #527bbd;\r
36   font-family: sans-serif;\r
37   margin-top: 1.2em;\r
38   margin-bottom: 0.5em;\r
39   line-height: 1.3;\r
40 }\r
41 \r
42 h1 {\r
43   border-bottom: 2px solid silver;\r
44 }\r
45 h2 {\r
46   border-bottom: 2px solid silver;\r
47   padding-top: 0.5em;\r
48 }\r
49 \r
50 div.sectionbody {\r
51   font-family: serif;\r
52   margin-left: 0;\r
53 }\r
54 \r
55 hr {\r
56   border: 1px solid silver;\r
57 }\r
58 \r
59 p {\r
60   margin-top: 0.5em;\r
61   margin-bottom: 0.5em;\r
62 }\r
63 \r
64 pre {\r
65   padding: 0;\r
66   margin: 0;\r
67 }\r
68 \r
69 span#author {\r
70   color: #527bbd;\r
71   font-family: sans-serif;\r
72   font-weight: bold;\r
73   font-size: 1.2em;\r
74 }\r
75 span#email {\r
76 }\r
77 span#revision {\r
78   font-family: sans-serif;\r
79 }\r
80 \r
81 div#footer {\r
82   font-family: sans-serif;\r
83   font-size: small;\r
84   border-top: 2px solid silver;\r
85   padding-top: 0.5em;\r
86   margin-top: 4.0em;\r
87 }\r
88 div#footer-text {\r
89   float: left;\r
90   padding-bottom: 0.5em;\r
91 }\r
92 div#footer-badges {\r
93   float: right;\r
94   padding-bottom: 0.5em;\r
95 }\r
96 \r
97 div#preamble,\r
98 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,\r
99 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,\r
100 div.admonitionblock {\r
101   margin-right: 10%;\r
102   margin-top: 1.5em;\r
103   margin-bottom: 1.5em;\r
104 }\r
105 div.admonitionblock {\r
106   margin-top: 2.5em;\r
107   margin-bottom: 2.5em;\r
108 }\r
109 \r
110 div.content { /* Block element content. */\r
111   padding: 0;\r
112 }\r
113 \r
114 /* Block element titles. */\r
115 div.title, caption.title {\r
116   font-family: sans-serif;\r
117   font-weight: bold;\r
118   text-align: left;\r
119   margin-top: 1.0em;\r
120   margin-bottom: 0.5em;\r
121 }\r
122 div.title + * {\r
123   margin-top: 0;\r
124 }\r
125 \r
126 td div.title:first-child {\r
127   margin-top: 0.0em;\r
128 }\r
129 div.content div.title:first-child {\r
130   margin-top: 0.0em;\r
131 }\r
132 div.content + div.title {\r
133   margin-top: 0.0em;\r
134 }\r
135 \r
136 div.sidebarblock > div.content {\r
137   background: #ffffee;\r
138   border: 1px solid silver;\r
139   padding: 0.5em;\r
140 }\r
141 \r
142 div.listingblock > div.content {\r
143   border: 1px solid silver;\r
144   background: #f4f4f4;\r
145   padding: 0.5em;\r
146 }\r
147 \r
148 div.quoteblock > div.content {\r
149   padding-left: 2.0em;\r
150 }\r
151 div.quoteblock .attribution {\r
152   text-align: right;\r
153 }\r
154 \r
155 div.admonitionblock .icon {\r
156   vertical-align: top;\r
157   font-size: 1.1em;\r
158   font-weight: bold;\r
159   text-decoration: underline;\r
160   color: #527bbd;\r
161   padding-right: 0.5em;\r
162 }\r
163 div.admonitionblock td.content {\r
164   padding-left: 0.5em;\r
165   border-left: 2px solid silver;\r
166 }\r
167 \r
168 div.exampleblock > div.content {\r
169   border-left: 2px solid silver;\r
170   padding: 0.5em;\r
171 }\r
172 \r
173 div.verseblock div.content {\r
174   white-space: pre;\r
175 }\r
176 \r
177 div.imageblock div.content { padding-left: 0; }\r
178 div.imageblock img { border: 1px solid silver; }\r
179 span.image img { border-style: none; }\r
180 \r
181 dl {\r
182   margin-top: 0.8em;\r
183   margin-bottom: 0.8em;\r
184 }\r
185 dt {\r
186   margin-top: 0.5em;\r
187   margin-bottom: 0;\r
188   font-style: italic;\r
189 }\r
190 dd > *:first-child {\r
191   margin-top: 0;\r
192 }\r
193 \r
194 ul, ol {\r
195     list-style-position: outside;\r
196 }\r
197 ol.olist2 {\r
198   list-style-type: lower-alpha;\r
199 }\r
200 \r
201 div.tableblock > table {\r
202   border-color: #527bbd;\r
203   border-width: 3px;\r
204 }\r
205 thead {\r
206   font-family: sans-serif;\r
207   font-weight: bold;\r
208 }\r
209 tfoot {\r
210   font-weight: bold;\r
211 }\r
212 \r
213 div.hlist {\r
214   margin-top: 0.8em;\r
215   margin-bottom: 0.8em;\r
216 }\r
217 td.hlist1 {\r
218   vertical-align: top;\r
219   font-style: italic;\r
220   padding-right: 0.8em;\r
221 }\r
222 td.hlist2 {\r
223   vertical-align: top;\r
224 }\r
225 \r
226 @media print {\r
227   div#footer-badges { display: none; }\r
228 }\r
229 /* Workarounds for IE6's broken and incomplete CSS2. */\r
230 \r
231 div.sidebar-content {\r
232   background: #ffffee;\r
233   border: 1px solid silver;\r
234   padding: 0.5em;\r
235 }\r
236 div.sidebar-title, div.image-title {\r
237   font-family: sans-serif;\r
238   font-weight: bold;\r
239   margin-top: 0.0em;\r
240   margin-bottom: 0.5em;\r
241 }\r
242 \r
243 div.listingblock div.content {\r
244   border: 1px solid silver;\r
245   background: #f4f4f4;\r
246   padding: 0.5em;\r
247 }\r
248 \r
249 div.quoteblock-content {\r
250   padding-left: 2.0em;\r
251 }\r
252 \r
253 div.exampleblock-content {\r
254   border-left: 2px solid silver;\r
255   padding-left: 0.5em;\r
256 }\r
257 </style>\r
258 <title>A tutorial introduction to git</title>\r
259 </head>\r
260 <body>\r
261 <div id="header">\r
262 <h1>A tutorial introduction to git</h1>\r
263 </div>\r
264 <div id="preamble">\r
265 <div class="sectionbody">\r
266 <p>This tutorial explains how to import a new project into git, make\r
267 changes to it, and share changes with other developers.</p>\r
268 <p>First, note that you can get documentation for a command such as "git\r
269 diff" with:</p>\r
270 <div class="listingblock">\r
271 <div class="content">\r
272 <pre><tt>$ man git-diff</tt></pre>\r
273 </div></div>\r
274 </div>\r
275 </div>\r
276 <h2>Importing a new project</h2>\r
277 <div class="sectionbody">\r
278 <p>Assume you have a tarball project.tar.gz with your initial work.  You\r
279 can place it under git revision control as follows.</p>\r
280 <div class="listingblock">\r
281 <div class="content">\r
282 <pre><tt>$ tar xzf project.tar.gz\r
283 $ cd project\r
284 $ git init-db</tt></pre>\r
285 </div></div>\r
286 <p>Git will reply</p>\r
287 <div class="listingblock">\r
288 <div class="content">\r
289 <pre><tt>defaulting to local storage area</tt></pre>\r
290 </div></div>\r
291 <p>You've now initialized the working directory&#8212;you may notice a new\r
292 directory created, named ".git".  Tell git that you want it to track\r
293 every file under the current directory with</p>\r
294 <div class="listingblock">\r
295 <div class="content">\r
296 <pre><tt>$ git add .</tt></pre>\r
297 </div></div>\r
298 <p>Finally,</p>\r
299 <div class="listingblock">\r
300 <div class="content">\r
301 <pre><tt>$ git commit -a</tt></pre>\r
302 </div></div>\r
303 <p>will prompt you for a commit message, then record the current state\r
304 of all the files to the repository.</p>\r
305 <p>Try modifying some files, then run</p>\r
306 <div class="listingblock">\r
307 <div class="content">\r
308 <pre><tt>$ git diff</tt></pre>\r
309 </div></div>\r
310 <p>to review your changes.  When you're done,</p>\r
311 <div class="listingblock">\r
312 <div class="content">\r
313 <pre><tt>$ git commit -a</tt></pre>\r
314 </div></div>\r
315 <p>will again prompt your for a message describing the change, and then\r
316 record the new versions of the modified files.</p>\r
317 <p>A note on commit messages: Though not required, it's a good idea to\r
318 begin the commit message with a single short (less than 50 character)\r
319 line summarizing the change, followed by a blank line and then a more\r
320 thorough description.  Tools that turn commits into email, for\r
321 example, use the first line on the Subject line and the rest of the\r
322 commit in the body.</p>\r
323 <p>To add a new file, first create the file, then</p>\r
324 <div class="listingblock">\r
325 <div class="content">\r
326 <pre><tt>$ git add path/to/new/file</tt></pre>\r
327 </div></div>\r
328 <p>then commit as usual.  No special command is required when removing a\r
329 file; just remove it, then commit.</p>\r
330 <p>At any point you can view the history of your changes using</p>\r
331 <div class="listingblock">\r
332 <div class="content">\r
333 <pre><tt>$ git log</tt></pre>\r
334 </div></div>\r
335 <p>If you also want to see complete diffs at each step, use</p>\r
336 <div class="listingblock">\r
337 <div class="content">\r
338 <pre><tt>$ git log -p</tt></pre>\r
339 </div></div>\r
340 </div>\r
341 <h2>Managing branches</h2>\r
342 <div class="sectionbody">\r
343 <p>A single git repository can maintain multiple branches of\r
344 development.  To create a new branch named "experimental", use</p>\r
345 <div class="listingblock">\r
346 <div class="content">\r
347 <pre><tt>$ git branch experimental</tt></pre>\r
348 </div></div>\r
349 <p>If you now run</p>\r
350 <div class="listingblock">\r
351 <div class="content">\r
352 <pre><tt>$ git branch</tt></pre>\r
353 </div></div>\r
354 <p>you'll get a list of all existing branches:</p>\r
355 <div class="listingblock">\r
356 <div class="content">\r
357 <pre><tt>  experimental\r
358 * master</tt></pre>\r
359 </div></div>\r
360 <p>The "experimental" branch is the one you just created, and the\r
361 "master" branch is a default branch that was created for you\r
362 automatically.  The asterisk marks the branch you are currently on;\r
363 type</p>\r
364 <div class="listingblock">\r
365 <div class="content">\r
366 <pre><tt>$ git checkout experimental</tt></pre>\r
367 </div></div>\r
368 <p>to switch to the experimental branch.  Now edit a file, commit the\r
369 change, and switch back to the master branch:</p>\r
370 <div class="listingblock">\r
371 <div class="content">\r
372 <pre><tt>(edit file)\r
373 $ git commit -a\r
374 $ git checkout master</tt></pre>\r
375 </div></div>\r
376 <p>Check that the change you made is no longer visible, since it was\r
377 made on the experimental branch and you're back on the master branch.</p>\r
378 <p>You can make a different change on the master branch:</p>\r
379 <div class="listingblock">\r
380 <div class="content">\r
381 <pre><tt>(edit file)\r
382 $ git commit -a</tt></pre>\r
383 </div></div>\r
384 <p>at this point the two branches have diverged, with different changes\r
385 made in each.  To merge the changes made in the two branches, run</p>\r
386 <div class="listingblock">\r
387 <div class="content">\r
388 <pre><tt>$ git pull . experimental</tt></pre>\r
389 </div></div>\r
390 <p>If the changes don't conflict, you're done.  If there are conflicts,\r
391 markers will be left in the problematic files showing the conflict;</p>\r
392 <div class="listingblock">\r
393 <div class="content">\r
394 <pre><tt>$ git diff</tt></pre>\r
395 </div></div>\r
396 <p>will show this.  Once you've edited the files to resolve the\r
397 conflicts,</p>\r
398 <div class="listingblock">\r
399 <div class="content">\r
400 <pre><tt>$ git commit -a</tt></pre>\r
401 </div></div>\r
402 <p>will commit the result of the merge. Finally,</p>\r
403 <div class="listingblock">\r
404 <div class="content">\r
405 <pre><tt>$ gitk</tt></pre>\r
406 </div></div>\r
407 <p>will show a nice graphical representation of the resulting history.</p>\r
408 <p>If you develop on a branch crazy-idea, then regret it, you can always\r
409 delete the branch with</p>\r
410 <div class="listingblock">\r
411 <div class="content">\r
412 <pre><tt>$ git branch -D crazy-idea</tt></pre>\r
413 </div></div>\r
414 <p>Branches are cheap and easy, so this is a good way to try something\r
415 out.</p>\r
416 </div>\r
417 <h2>Using git for collaboration</h2>\r
418 <div class="sectionbody">\r
419 <p>Suppose that Alice has started a new project with a git repository in\r
420 /home/alice/project, and that Bob, who has a home directory on the\r
421 same machine, wants to contribute.</p>\r
422 <p>Bob begins with:</p>\r
423 <div class="listingblock">\r
424 <div class="content">\r
425 <pre><tt>$ git clone /home/alice/project myrepo</tt></pre>\r
426 </div></div>\r
427 <p>This creates a new directory "myrepo" containing a clone of Alice's\r
428 repository.  The clone is on an equal footing with the original\r
429 project, possessing its own copy of the original project's history.</p>\r
430 <p>Bob then makes some changes and commits them:</p>\r
431 <div class="listingblock">\r
432 <div class="content">\r
433 <pre><tt>(edit files)\r
434 $ git commit -a\r
435 (repeat as necessary)</tt></pre>\r
436 </div></div>\r
437 <p>When he's ready, he tells Alice to pull changes from the repository\r
438 at /home/bob/myrepo.  She does this with:</p>\r
439 <div class="listingblock">\r
440 <div class="content">\r
441 <pre><tt>$ cd /home/alice/project\r
442 $ git pull /home/bob/myrepo</tt></pre>\r
443 </div></div>\r
444 <p>This actually pulls changes from the branch in Bob's repository named\r
445 "master".  Alice could request a different branch by adding the name\r
446 of the branch to the end of the git pull command line.</p>\r
447 <p>This merges Bob's changes into her repository; "git log" will\r
448 now show the new commits.  If Alice has made her own changes in the\r
449 meantime, then Bob's changes will be merged in, and she will need to\r
450 manually fix any conflicts.</p>\r
451 <p>A more cautious Alice might wish to examine Bob's changes before\r
452 pulling them.  She can do this by creating a temporary branch just\r
453 for the purpose of studying Bob's changes:</p>\r
454 <div class="listingblock">\r
455 <div class="content">\r
456 <pre><tt>$ git fetch /home/bob/myrepo master:bob-incoming</tt></pre>\r
457 </div></div>\r
458 <p>which fetches the changes from Bob's master branch into a new branch\r
459 named bob-incoming.  (Unlike git pull, git fetch just fetches a copy\r
460 of Bob's line of development without doing any merging).  Then</p>\r
461 <div class="listingblock">\r
462 <div class="content">\r
463 <pre><tt>$ git log -p master..bob-incoming</tt></pre>\r
464 </div></div>\r
465 <p>shows a list of all the changes that Bob made since he branched from\r
466 Alice's master branch.</p>\r
467 <p>After examining those changes, and possibly fixing things, Alice can\r
468 pull the changes into her master branch:</p>\r
469 <div class="listingblock">\r
470 <div class="content">\r
471 <pre><tt>$ git checkout master\r
472 $ git pull . bob-incoming</tt></pre>\r
473 </div></div>\r
474 <p>The last command is a pull from the "bob-incoming" branch in Alice's\r
475 own repository.</p>\r
476 <p>Later, Bob can update his repo with Alice's latest changes using</p>\r
477 <div class="listingblock">\r
478 <div class="content">\r
479 <pre><tt>$ git pull</tt></pre>\r
480 </div></div>\r
481 <p>Note that he doesn't need to give the path to Alice's repository;\r
482 when Bob cloned Alice's repository, git stored the location of her\r
483 repository in the file .git/remotes/origin, and that location is used\r
484 as the default for pulls.</p>\r
485 <p>Bob may also notice a branch in his repository that he didn't create:</p>\r
486 <div class="listingblock">\r
487 <div class="content">\r
488 <pre><tt>$ git branch\r
489 * master\r
490   origin</tt></pre>\r
491 </div></div>\r
492 <p>The "origin" branch, which was created automatically by "git clone",\r
493 is a pristine copy of Alice's master branch; Bob should never commit\r
494 to it.</p>\r
495 <p>If Bob later decides to work from a different host, he can still\r
496 perform clones and pulls using the ssh protocol:</p>\r
497 <div class="listingblock">\r
498 <div class="content">\r
499 <pre><tt>$ git clone alice.org:/home/alice/project myrepo</tt></pre>\r
500 </div></div>\r
501 <p>Alternatively, git has a native protocol, or can use rsync or http;\r
502 see <a href="git-pull.html">git-pull(1)</a> for details.</p>\r
503 <p>Git can also be used in a CVS-like mode, with a central repository\r
504 that various users push changes to; see <a href="git-push.html">git-push(1)</a> and\r
505 <a href="cvs-migration.html">git for CVS users</a>.</p>\r
506 </div>\r
507 <h2>Exploring history</h2>\r
508 <div class="sectionbody">\r
509 <p>Git history is represented as a series of interrelated commits.  We\r
510 have already seen that the git log command can list those commits.\r
511 Note that first line of each git log entry also gives a name for the\r
512 commit:</p>\r
513 <div class="listingblock">\r
514 <div class="content">\r
515 <pre><tt>$ git log\r
516 commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7\r
517 Author: Junio C Hamano &lt;junkio@cox.net&gt;\r
518 Date:   Tue May 16 17:18:22 2006 -0700\r
519 \r
520     merge-base: Clarify the comments on post processing.</tt></pre>\r
521 </div></div>\r
522 <p>We can give this name to git show to see the details about this\r
523 commit.</p>\r
524 <div class="listingblock">\r
525 <div class="content">\r
526 <pre><tt>$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7</tt></pre>\r
527 </div></div>\r
528 <p>But there other ways to refer to commits.  You can use any initial\r
529 part of the name that is long enough to uniquely identify the commit:</p>\r
530 <div class="listingblock">\r
531 <div class="content">\r
532 <pre><tt>$ git show c82a22c39c   # the first few characters of the name are\r
533                         # usually enough\r
534 $ git show HEAD         # the tip of the current branch\r
535 $ git show experimental # the tip of the "experimental" branch</tt></pre>\r
536 </div></div>\r
537 <p>Every commit has at least one "parent" commit, which points to the\r
538 previous state of the project:</p>\r
539 <div class="listingblock">\r
540 <div class="content">\r
541 <pre><tt>$ git show HEAD^  # to see the parent of HEAD\r
542 $ git show HEAD^^ # to see the grandparent of HEAD\r
543 $ git show HEAD~4 # to see the great-great grandparent of HEAD</tt></pre>\r
544 </div></div>\r
545 <p>Note that merge commits may have more than one parent:</p>\r
546 <div class="listingblock">\r
547 <div class="content">\r
548 <pre><tt>$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^)\r
549 $ git show HEAD^2 # show the second parent of HEAD</tt></pre>\r
550 </div></div>\r
551 <p>You can also give commits names of your own; after running</p>\r
552 <div class="listingblock">\r
553 <div class="content">\r
554 <pre><tt>$ git-tag v2.5 1b2e1d63ff</tt></pre>\r
555 </div></div>\r
556 <p>you can refer to 1b2e1d63ff by the name "v2.5".  If you intend to\r
557 share this name with other people (for example, to identify a release\r
558 version), you should create a "tag" object, and perhaps sign it; see\r
559 <a href="git-tag.html">git-tag(1)</a> for details.</p>\r
560 <p>Any git command that needs to know a commit can take any of these\r
561 names.  For example:</p>\r
562 <div class="listingblock">\r
563 <div class="content">\r
564 <pre><tt>$ git diff v2.5 HEAD     # compare the current HEAD to v2.5\r
565 $ git branch stable v2.5 # start a new branch named "stable" based\r
566                          # at v2.5\r
567 $ git reset --hard HEAD^ # reset your current branch and working\r
568                          # directory to its state at HEAD^</tt></pre>\r
569 </div></div>\r
570 <p>Be careful with that last command: in addition to losing any changes\r
571 in the working directory, it will also remove all later commits from\r
572 this branch.  If this branch is the only branch containing those\r
573 commits, they will be lost.  (Also, don't use "git reset" on a\r
574 publicly-visible branch that other developers pull from, as git will\r
575 be confused by history that disappears in this way.)</p>\r
576 <p>The git grep command can search for strings in any version of your\r
577 project, so</p>\r
578 <div class="listingblock">\r
579 <div class="content">\r
580 <pre><tt>$ git grep "hello" v2.5</tt></pre>\r
581 </div></div>\r
582 <p>searches for all occurrences of "hello" in v2.5.</p>\r
583 <p>If you leave out the commit name, git grep will search any of the\r
584 files it manages in your current directory.  So</p>\r
585 <div class="listingblock">\r
586 <div class="content">\r
587 <pre><tt>$ git grep "hello"</tt></pre>\r
588 </div></div>\r
589 <p>is a quick way to search just the files that are tracked by git.</p>\r
590 <p>Many git commands also take sets of commits, which can be specified\r
591 in a number of ways.  Here are some examples with git log:</p>\r
592 <div class="listingblock">\r
593 <div class="content">\r
594 <pre><tt>$ git log v2.5..v2.6            # commits between v2.5 and v2.6\r
595 $ git log v2.5..                # commits since v2.5\r
596 $ git log --since="2 weeks ago" # commits from the last 2 weeks\r
597 $ git log v2.5.. Makefile       # commits since v2.5 which modify\r
598                                 # Makefile</tt></pre>\r
599 </div></div>\r
600 <p>You can also give git log a "range" of commits where the first is not\r
601 necessarily an ancestor of the second; for example, if the tips of\r
602 the branches "stable-release" and "master" diverged from a common\r
603 commit some time ago, then</p>\r
604 <div class="listingblock">\r
605 <div class="content">\r
606 <pre><tt>$ git log stable..experimental</tt></pre>\r
607 </div></div>\r
608 <p>will list commits made in the experimental branch but not in the\r
609 stable branch, while</p>\r
610 <div class="listingblock">\r
611 <div class="content">\r
612 <pre><tt>$ git log experimental..stable</tt></pre>\r
613 </div></div>\r
614 <p>will show the list of commits made on the stable branch but not\r
615 the experimental branch.</p>\r
616 <p>The "git log" command has a weakness: it must present commits in a\r
617 list.  When the history has lines of development that diverged and\r
618 then merged back together, the order in which "git log" presents\r
619 those commits is meaningless.</p>\r
620 <p>Most projects with multiple contributors (such as the linux kernel,\r
621 or git itself) have frequent merges, and gitk does a better job of\r
622 visualizing their history.  For example,</p>\r
623 <div class="listingblock">\r
624 <div class="content">\r
625 <pre><tt>$ gitk --since="2 weeks ago" drivers/</tt></pre>\r
626 </div></div>\r
627 <p>allows you to browse any commits from the last 2 weeks of commits\r
628 that modified files under the "drivers" directory.  (Note: you can\r
629 adjust gitk's fonts by holding down the control key while pressing\r
630 "-" or "+".)</p>\r
631 <p>Finally, most commands that take filenames will optionally allow you\r
632 to precede any filename by a commit, to specify a particular version\r
633 of the file:</p>\r
634 <div class="listingblock">\r
635 <div class="content">\r
636 <pre><tt>$ git diff v2.5:Makefile HEAD:Makefile.in</tt></pre>\r
637 </div></div>\r
638 <p>You can also use "git cat-file -p" to see any such file:</p>\r
639 <div class="listingblock">\r
640 <div class="content">\r
641 <pre><tt>$ git cat-file -p v2.5:Makefile</tt></pre>\r
642 </div></div>\r
643 </div>\r
644 <h2>Next Steps</h2>\r
645 <div class="sectionbody">\r
646 <p>This tutorial should be enough to perform basic distributed revision\r
647 control for your projects.  However, to fully understand the depth\r
648 and power of git you need to understand two simple ideas on which it\r
649 is based:</p>\r
650 <ul>\r
651 <li>\r
652 <p>\r
653 The object database is the rather elegant system used to\r
654     store the history of your project&#8212;files, directories, and\r
655     commits.\r
656 </p>\r
657 </li>\r
658 <li>\r
659 <p>\r
660 The index file is a cache of the state of a directory tree,\r
661     used to create commits, check out working directories, and\r
662     hold the various trees involved in a merge.\r
663 </p>\r
664 </li>\r
665 </ul>\r
666 <p><a href="tutorial-2.html">Part two of this tutorial</a> explains the object\r
667 database, the index file, and a few other odds and ends that you'll\r
668 need to make the most of git.</p>\r
669 <p>If you don't want to consider with that right away, a few other\r
670 digressions that may be interesting at this point are:</p>\r
671 <ul>\r
672 <li>\r
673 <p>\r
674 <a href="git-format-patch.html">git-format-patch(1)</a>, <a href="git-am.html">git-am(1)</a>: These convert\r
675     series of git commits into emailed patches, and vice versa,\r
676     useful for projects such as the linux kernel which rely heavily\r
677     on emailed patches.\r
678 </p>\r
679 </li>\r
680 <li>\r
681 <p>\r
682 <a href="git-bisect.html">git-bisect(1)</a>: When there is a regression in your\r
683     project, one way to track down the bug is by searching through\r
684     the history to find the exact commit that's to blame.  Git bisect\r
685     can help you perform a binary search for that commit.  It is\r
686     smart enough to perform a close-to-optimal search even in the\r
687     case of complex non-linear history with lots of merged branches.\r
688 </p>\r
689 </li>\r
690 <li>\r
691 <p>\r
692 <a href="everyday.html">Everyday GIT with 20 Commands Or So</a>\r
693 </p>\r
694 </li>\r
695 <li>\r
696 <p>\r
697 <a href="cvs-migration.html">git for CVS users</a>.\r
698 </p>\r
699 </li>\r
700 </ul>\r
701 </div>\r
702 <div id="footer">\r
703 <div id="footer-text">\r
704 Last updated 07-Jun-2006 19:51:35 UTC\r
705 </div>\r
706 </div>\r
707 </body>\r
708 </html>\r