blob: 86bc65b57c316efb0a5ccd712327f64ee57512f9 [file] [log] [blame]
Junio C Hamano1a4e8412005-12-27 08:17:231<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Junio C Hamano40f2f8d2006-02-07 08:04:396<meta name="generator" content="AsciiDoc 7.0.2" />
Junio C Hamano1a4e8412005-12-27 08:17:237<style type="text/css">
8/* Debug borders */
9p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
10/*
11 border: 1px solid red;
12*/
13}
14
15body {
16 margin: 1em 5% 1em 5%;
17}
18
19a { color: blue; }
20a:visited { color: fuchsia; }
21
22em {
23 font-style: italic;
24}
25
26strong {
27 font-weight: bold;
28}
29
30tt {
31 color: navy;
32}
33
34h1, h2, h3, h4, h5, h6 {
35 color: #527bbd;
36 font-family: sans-serif;
37 margin-top: 1.2em;
38 margin-bottom: 0.5em;
39 line-height: 1.3;
40}
41
42h1 {
43 border-bottom: 2px solid silver;
44}
45h2 {
46 border-bottom: 2px solid silver;
47 padding-top: 0.5em;
48}
49
50div.sectionbody {
51 font-family: serif;
52 margin-left: 0;
53}
54
55hr {
56 border: 1px solid silver;
57}
58
59p {
60 margin-top: 0.5em;
61 margin-bottom: 0.5em;
62}
63
64pre {
65 padding: 0;
66 margin: 0;
67}
68
69span#author {
70 color: #527bbd;
71 font-family: sans-serif;
72 font-weight: bold;
73 font-size: 1.2em;
74}
75span#email {
76}
77span#revision {
78 font-family: sans-serif;
79}
80
81div#footer {
82 font-family: sans-serif;
83 font-size: small;
84 border-top: 2px solid silver;
85 padding-top: 0.5em;
86 margin-top: 4.0em;
87}
88div#footer-text {
89 float: left;
90 padding-bottom: 0.5em;
91}
92div#footer-badges {
93 float: right;
94 padding-bottom: 0.5em;
95}
96
97div#preamble,
98div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
99div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
100div.admonitionblock {
101 margin-right: 10%;
102 margin-top: 1.5em;
103 margin-bottom: 1.5em;
104}
105div.admonitionblock {
106 margin-top: 2.5em;
107 margin-bottom: 2.5em;
108}
109
110div.content { /* Block element content. */
111 padding: 0;
112}
113
114/* Block element titles. */
115div.title, caption.title {
116 font-family: sans-serif;
117 font-weight: bold;
118 text-align: left;
119 margin-top: 1.0em;
120 margin-bottom: 0.5em;
121}
122div.title + * {
123 margin-top: 0;
124}
125
126td div.title:first-child {
127 margin-top: 0.0em;
128}
129div.content div.title:first-child {
130 margin-top: 0.0em;
131}
132div.content + div.title {
133 margin-top: 0.0em;
134}
135
136div.sidebarblock > div.content {
137 background: #ffffee;
138 border: 1px solid silver;
139 padding: 0.5em;
140}
141
142div.listingblock > div.content {
143 border: 1px solid silver;
144 background: #f4f4f4;
145 padding: 0.5em;
146}
147
148div.quoteblock > div.content {
149 padding-left: 2.0em;
150}
151div.quoteblock .attribution {
152 text-align: right;
153}
154
155div.admonitionblock .icon {
156 vertical-align: top;
157 font-size: 1.1em;
158 font-weight: bold;
159 text-decoration: underline;
160 color: #527bbd;
161 padding-right: 0.5em;
162}
163div.admonitionblock td.content {
164 padding-left: 0.5em;
165 border-left: 2px solid silver;
166}
167
168div.exampleblock > div.content {
169 border-left: 2px solid silver;
170 padding: 0.5em;
171}
172
173div.verseblock div.content {
174 white-space: pre;
175}
176
177div.imageblock div.content { padding-left: 0; }
178div.imageblock img { border: 1px solid silver; }
179span.image img { border-style: none; }
180
181dl {
182 margin-top: 0.8em;
183 margin-bottom: 0.8em;
184}
185dt {
186 margin-top: 0.5em;
187 margin-bottom: 0;
188 font-style: italic;
189}
190dd > *:first-child {
191 margin-top: 0;
192}
193
194ul, ol {
195 list-style-position: outside;
196}
197ol.olist2 {
198 list-style-type: lower-alpha;
199}
200
201div.tableblock > table {
202 border-color: #527bbd;
203 border-width: 3px;
204}
205thead {
206 font-family: sans-serif;
207 font-weight: bold;
208}
209tfoot {
210 font-weight: bold;
211}
212
213div.hlist {
214 margin-top: 0.8em;
215 margin-bottom: 0.8em;
216}
217td.hlist1 {
218 vertical-align: top;
219 font-style: italic;
220 padding-right: 0.8em;
221}
222td.hlist2 {
223 vertical-align: top;
224}
225
226@media print {
227 div#footer-badges { display: none; }
228}
229include::./stylesheets/xhtml11-manpage.css[]
230/* Workarounds for IE6's broken and incomplete CSS2. */
231
232div.sidebar-content {
233 background: #ffffee;
234 border: 1px solid silver;
235 padding: 0.5em;
236}
237div.sidebar-title, div.image-title {
238 font-family: sans-serif;
239 font-weight: bold;
240 margin-top: 0.0em;
241 margin-bottom: 0.5em;
242}
243
244div.listingblock div.content {
245 border: 1px solid silver;
246 background: #f4f4f4;
247 padding: 0.5em;
248}
249
250div.quoteblock-content {
251 padding-left: 2.0em;
252}
253
254div.exampleblock-content {
255 border-left: 2px solid silver;
256 padding-left: 0.5em;
257}
258</style>
259<title>git(7)</title>
260</head>
261<body>
262<div id="header">
263<h1>
264git(7) Manual Page
265</h1>
266<h2>NAME</h2>
267<div class="sectionbody">
268<p>git -
269 the stupid content tracker
270</p>
271</div>
272</div>
273<h2>SYNOPSIS</h2>
274<div class="sectionbody">
Junio C Hamano6b2cee12006-08-26 08:43:31275<div class="verseblock">
276<div class="content"><em>git</em> [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
277 [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]</div></div>
Junio C Hamano1a4e8412005-12-27 08:17:23278</div>
279<h2>DESCRIPTION</h2>
280<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10281<p>Git is a fast, scalable, distributed revision control system with an
282unusually rich command set that provides both high-level operations
283and full access to internals.</p>
284<p>See this <a href="tutorial.html">tutorial</a> to get started, then see
285<a href="everyday.html">Everyday Git</a> for a useful minimum set of commands, and
286"man git-commandname" for documentation of each command. CVS users may
Junio C Hamano8f62db92007-02-01 00:22:22287also want to read <a href="cvs-migration.html">CVS migration</a>.
288<a href="user-manual.html">Git User's Manual</a> is still work in
289progress, but when finished hopefully it will guide a new user
290in a coherent way to git enlightenment ;-).</p>
Junio C Hamano33db4372006-06-07 19:51:45291<p>The COMMAND is either a name of a Git command (see below) or an alias
Junio C Hamano7ad22dc2007-01-29 02:55:48292as defined in the configuration file (see <a href="git-config.html">git-config(1)</a>).</p>
Junio C Hamano1a4e8412005-12-27 08:17:23293</div>
294<h2>OPTIONS</h2>
295<div class="sectionbody">
296<dl>
297<dt>
298--version
299</dt>
300<dd>
301<p>
Junio C Hamano01078922006-03-10 00:31:47302 Prints the git suite version that the <em>git</em> program came from.
Junio C Hamano1a4e8412005-12-27 08:17:23303</p>
304</dd>
305<dt>
306--help
307</dt>
308<dd>
309<p>
Junio C Hamano01078922006-03-10 00:31:47310 Prints the synopsis and a list of the most commonly used
311 commands. If a git command is named this option will bring up
312 the man-page for that command. If the option <em>--all</em> or <em>-a</em> is
313 given then all available commands are printed.
Junio C Hamano1a4e8412005-12-27 08:17:23314</p>
315</dd>
316<dt>
317--exec-path
318</dt>
319<dd>
320<p>
Junio C Hamano01078922006-03-10 00:31:47321 Path to wherever your core git programs are installed.
Junio C Hamano1a4e8412005-12-27 08:17:23322 This can also be controlled by setting the GIT_EXEC_PATH
323 environment variable. If no path is given <em>git</em> will print
324 the current setting and then exit.
325</p>
326</dd>
Junio C Hamanof870ef82006-07-29 09:10:13327<dt>
328-p|--paginate
329</dt>
330<dd>
331<p>
332 Pipe all output into <em>less</em> (or if set, $PAGER).
333</p>
334</dd>
335<dt>
336--git-dir=&lt;path&gt;
337</dt>
338<dd>
339<p>
340 Set the path to the repository. This can also be controlled by
341 setting the GIT_DIR environment variable.
342</p>
343</dd>
344<dt>
345--bare
346</dt>
347<dd>
348<p>
349 Same as --git-dir=<tt>pwd</tt>.
350</p>
351</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23352</dl>
353</div>
Junio C Hamanoe27fb932006-04-03 05:34:10354<h2>FURTHER DOCUMENTATION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23355<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10356<p>See the references above to get started using git. The following is
357probably more detail than necessary for a first-time user.</p>
358<p>The <a href="#Discussion">Discussion</a> section below and the
359<a href="core-tutorial.html">Core tutorial</a> both provide introductions to the
360underlying git architecture.</p>
361<p>See also the <a href="howto-index.html">howto</a> documents for some useful
362examples.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23363</div>
Junio C Hamanoe27fb932006-04-03 05:34:10364<h2>GIT COMMANDS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23365<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10366<p>We divide git into high level ("porcelain") commands and low level
367("plumbing") commands.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23368</div>
Junio C Hamanoe27fb932006-04-03 05:34:10369<h2>High-level commands (porcelain)</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23370<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10371<p>We separate the porcelain commands into the main commands and some
372ancillary user utilities.</p>
373<h3>Main porcelain commands</h3>
Junio C Hamano1a4e8412005-12-27 08:17:23374<dl>
375<dt>
376<a href="git-add.html">git-add(1)</a>
377</dt>
378<dd>
379<p>
Junio C Hamano7c73c662007-01-19 00:37:50380 Add file contents to the changeset to be committed next.
Junio C Hamano1a4e8412005-12-27 08:17:23381</p>
382</dd>
383<dt>
384<a href="git-am.html">git-am(1)</a>
385</dt>
386<dd>
387<p>
Junio C Hamano7c73c662007-01-19 00:37:50388 Apply a series of patches from a mailbox.
Junio C Hamano1a4e8412005-12-27 08:17:23389</p>
390</dd>
391<dt>
Junio C Hamano817abb42006-09-26 07:16:58392<a href="git-archive.html">git-archive(1)</a>
393</dt>
394<dd>
395<p>
396 Creates an archive of files from a named tree.
397</p>
398</dd>
399<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23400<a href="git-bisect.html">git-bisect(1)</a>
401</dt>
402<dd>
403<p>
404 Find the change that introduced a bug by binary search.
405</p>
406</dd>
407<dt>
408<a href="git-branch.html">git-branch(1)</a>
409</dt>
410<dd>
411<p>
Junio C Hamano7c73c662007-01-19 00:37:50412 List, create, or delete branches.
Junio C Hamano1a4e8412005-12-27 08:17:23413</p>
414</dd>
415<dt>
416<a href="git-checkout.html">git-checkout(1)</a>
417</dt>
418<dd>
419<p>
420 Checkout and switch to a branch.
421</p>
422</dd>
423<dt>
424<a href="git-cherry-pick.html">git-cherry-pick(1)</a>
425</dt>
426<dd>
427<p>
Junio C Hamano7c73c662007-01-19 00:37:50428 Apply the change introduced by an existing commit.
Junio C Hamano1a4e8412005-12-27 08:17:23429</p>
430</dd>
431<dt>
Junio C Hamano54559c82006-04-13 07:45:12432<a href="git-clean.html">git-clean(1)</a>
433</dt>
434<dd>
435<p>
436 Remove untracked files from the working tree.
437</p>
438</dd>
439<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23440<a href="git-clone.html">git-clone(1)</a>
441</dt>
442<dd>
443<p>
444 Clones a repository into a new directory.
445</p>
446</dd>
447<dt>
448<a href="git-commit.html">git-commit(1)</a>
449</dt>
450<dd>
451<p>
452 Record changes to the repository.
453</p>
454</dd>
455<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50456<a href="git-describe.html">git-describe(1)</a>
457</dt>
458<dd>
459<p>
460 Show the most recent tag that is reachable from a commit.
461</p>
462</dd>
463<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23464<a href="git-diff.html">git-diff(1)</a>
465</dt>
466<dd>
467<p>
468 Show changes between commits, commit and working tree, etc.
469</p>
470</dd>
471<dt>
472<a href="git-fetch.html">git-fetch(1)</a>
473</dt>
474<dd>
475<p>
Junio C Hamano7c73c662007-01-19 00:37:50476 Download objects and refs from another repository.
Junio C Hamano1a4e8412005-12-27 08:17:23477</p>
478</dd>
479<dt>
480<a href="git-format-patch.html">git-format-patch(1)</a>
481</dt>
482<dd>
483<p>
484 Prepare patches for e-mail submission.
485</p>
486</dd>
487<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50488<a href="git-gc.html">git-gc(1)</a>
489</dt>
490<dd>
491<p>
492 Cleanup unnecessary files and optimize the local repository.
493</p>
494</dd>
495<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23496<a href="git-grep.html">git-grep(1)</a>
497</dt>
498<dd>
499<p>
500 Print lines matching a pattern.
501</p>
502</dd>
503<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50504<a href="git-init.html">git-init(1)</a>
505</dt>
506<dd>
507<p>
508 Create an empty git repository or reinitialize an existing one.
509</p>
510</dd>
511<dt>
Junio C Hamanoeb8e3572006-09-01 08:25:07512<a href="gitk.html">gitk(1)</a>
513</dt>
514<dd>
515<p>
516 The git repository browser.
517</p>
518</dd>
519<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23520<a href="git-log.html">git-log(1)</a>
521</dt>
522<dd>
523<p>
Junio C Hamano7c73c662007-01-19 00:37:50524 Show commit logs.
Junio C Hamano1a4e8412005-12-27 08:17:23525</p>
526</dd>
527<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23528<a href="git-merge.html">git-merge(1)</a>
529</dt>
530<dd>
531<p>
Junio C Hamano7c73c662007-01-19 00:37:50532 Join two or more development histories together.
Junio C Hamano1a4e8412005-12-27 08:17:23533</p>
534</dd>
535<dt>
536<a href="git-mv.html">git-mv(1)</a>
537</dt>
538<dd>
539<p>
540 Move or rename a file, a directory, or a symlink.
541</p>
542</dd>
543<dt>
544<a href="git-pull.html">git-pull(1)</a>
545</dt>
546<dd>
547<p>
Junio C Hamano7c73c662007-01-19 00:37:50548 Fetch from and merge with another repository or a local branch.
Junio C Hamano1a4e8412005-12-27 08:17:23549</p>
550</dd>
551<dt>
552<a href="git-push.html">git-push(1)</a>
553</dt>
554<dd>
555<p>
556 Update remote refs along with associated objects.
557</p>
558</dd>
559<dt>
560<a href="git-rebase.html">git-rebase(1)</a>
561</dt>
562<dd>
563<p>
Junio C Hamano7c73c662007-01-19 00:37:50564 Forward-port local commits to the updated upstream head.
Junio C Hamano1a4e8412005-12-27 08:17:23565</p>
566</dd>
567<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23568<a href="git-reset.html">git-reset(1)</a>
569</dt>
570<dd>
571<p>
572 Reset current HEAD to the specified state.
573</p>
574</dd>
575<dt>
576<a href="git-resolve.html">git-resolve(1)</a>
577</dt>
578<dd>
579<p>
580 Merge two commits.
581</p>
582</dd>
583<dt>
584<a href="git-revert.html">git-revert(1)</a>
585</dt>
586<dd>
587<p>
588 Revert an existing commit.
589</p>
590</dd>
591<dt>
Junio C Hamano54559c82006-04-13 07:45:12592<a href="git-rm.html">git-rm(1)</a>
593</dt>
594<dd>
595<p>
596 Remove files from the working tree and from the index.
597</p>
598</dd>
599<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23600<a href="git-shortlog.html">git-shortlog(1)</a>
601</dt>
602<dd>
603<p>
Junio C Hamano7c73c662007-01-19 00:37:50604 Summarize <em>git log</em> output.
Junio C Hamano1a4e8412005-12-27 08:17:23605</p>
606</dd>
607<dt>
Junio C Hamano2b135272006-03-18 07:45:42608<a href="git-show.html">git-show(1)</a>
609</dt>
610<dd>
611<p>
Junio C Hamano7c73c662007-01-19 00:37:50612 Show various types of objects.
Junio C Hamano2b135272006-03-18 07:45:42613</p>
614</dd>
615<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23616<a href="git-status.html">git-status(1)</a>
617</dt>
618<dd>
619<p>
Junio C Hamano7c73c662007-01-19 00:37:50620 Show the working tree status.
Junio C Hamano1a4e8412005-12-27 08:17:23621</p>
622</dd>
623<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50624<a href="git-tag.html">git-tag(1)</a>
625</dt>
626<dd>
627<p>
Junio C Hamanodb450ba2007-01-21 08:57:14628 Create, list, delete or verify a tag object signed with GPG.
Junio C Hamano4ad294b2007-01-20 02:22:50629</p>
630</dd>
631</dl>
632<h3>Ancillary Commands</h3>
633<p>Manipulators:</p>
634<dl>
635<dt>
636<a href="git-convert-objects.html">git-convert-objects(1)</a>
637</dt>
638<dd>
639<p>
640 Converts old-style git repository.
641</p>
642</dd>
643<dt>
Junio C Hamanodfc4ce72007-02-07 23:17:29644<a href="git-fast-import.html">git-fast-import(1)</a>
645</dt>
646<dd>
647<p>
648 Backend for fast Git data importers..
649</p>
650</dd>
651<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50652<a href="git-lost-found.html">git-lost-found(1)</a>
653</dt>
654<dd>
655<p>
656 Recover lost refs that luckily have not yet been pruned.
657</p>
658</dd>
659<dt>
660<a href="git-pack-refs.html">git-pack-refs(1)</a>
661</dt>
662<dd>
663<p>
664 Pack heads and tags for efficient repository access.
665</p>
666</dd>
667<dt>
668<a href="git-prune.html">git-prune(1)</a>
669</dt>
670<dd>
671<p>
672 Prunes all unreachable objects from the object database.
673</p>
674</dd>
675<dt>
676<a href="git-reflog.html">git-reflog(1)</a>
677</dt>
678<dd>
679<p>
680 Manage reflog information.
681</p>
682</dd>
683<dt>
684<a href="git-relink.html">git-relink(1)</a>
685</dt>
686<dd>
687<p>
688 Hardlink common objects in local repositories.
689</p>
690</dd>
691<dt>
692<a href="git-repack.html">git-repack(1)</a>
693</dt>
694<dd>
695<p>
696 Pack unpacked objects in a repository.
697</p>
698</dd>
699<dt>
Junio C Hamano7ad22dc2007-01-29 02:55:48700<a href="git-config.html">git-config(1)</a>
Junio C Hamano4ad294b2007-01-20 02:22:50701</dt>
702<dd>
703<p>
704 Get and set repository or global options.
705</p>
706</dd>
707</dl>
708<p>Interrogators:</p>
709<dl>
710<dt>
711<a href="git-annotate.html">git-annotate(1)</a>
712</dt>
713<dd>
714<p>
715 Annotate file lines with commit info.
716</p>
717</dd>
718<dt>
719<a href="git-applymbox.html">git-applymbox(1)</a>
720</dt>
721<dd>
722<p>
723 Apply a series of patches in a mailbox.
724</p>
725</dd>
726<dt>
727<a href="git-blame.html">git-blame(1)</a>
728</dt>
729<dd>
730<p>
731 Show what revision and author last modified each line of a file.
732</p>
733</dd>
734<dt>
735<a href="git-cherry.html">git-cherry(1)</a>
736</dt>
737<dd>
738<p>
739 Find commits not merged upstream.
740</p>
741</dd>
742<dt>
743<a href="git-count-objects.html">git-count-objects(1)</a>
744</dt>
745<dd>
746<p>
747 Count unpacked number of objects and their disk consumption.
748</p>
749</dd>
750<dt>
Junio C Hamano7ad22dc2007-01-29 02:55:48751<a href="git-fsck.html">git-fsck(1)</a>
Junio C Hamano4ad294b2007-01-20 02:22:50752</dt>
753<dd>
754<p>
755 Verifies the connectivity and validity of the objects in the database.
756</p>
757</dd>
758<dt>
759<a href="git-get-tar-commit-id.html">git-get-tar-commit-id(1)</a>
760</dt>
761<dd>
762<p>
763 Extract commit ID from an archive created using git-tar-tree.
764</p>
765</dd>
766<dt>
767<a href="git-instaweb.html">git-instaweb(1)</a>
768</dt>
769<dd>
770<p>
771 Instantly browse your working repository in gitweb.
772</p>
773</dd>
774<dt>
775<a href="git-merge-tree.html">git-merge-tree(1)</a>
776</dt>
777<dd>
778<p>
779 Show three-way merge without touching index.
780</p>
781</dd>
782<dt>
783<a href="git-rerere.html">git-rerere(1)</a>
784</dt>
785<dd>
786<p>
787 Reuse recorded resolution of conflicted merges.
788</p>
789</dd>
790<dt>
791<a href="git-rev-parse.html">git-rev-parse(1)</a>
792</dt>
793<dd>
794<p>
795 Pick out and massage parameters.
796</p>
797</dd>
798<dt>
799<a href="git-runstatus.html">git-runstatus(1)</a>
800</dt>
801<dd>
802<p>
803 A helper for git-status and git-commit.
804</p>
805</dd>
806<dt>
807<a href="git-show-branch.html">git-show-branch(1)</a>
808</dt>
809<dd>
810<p>
811 Show branches and their commits.
812</p>
813</dd>
814<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23815<a href="git-verify-tag.html">git-verify-tag(1)</a>
816</dt>
817<dd>
818<p>
819 Check the GPG signature of tag.
820</p>
821</dd>
822<dt>
823<a href="git-whatchanged.html">git-whatchanged(1)</a>
824</dt>
825<dd>
826<p>
Junio C Hamano7c73c662007-01-19 00:37:50827 Show logs with difference each commit introduces.
Junio C Hamano1a4e8412005-12-27 08:17:23828</p>
829</dd>
830</dl>
Junio C Hamano4ad294b2007-01-20 02:22:50831<h3>Interacting with Others</h3>
832<p>These commands are to interact with foreign SCM and with other
833people via patch over e-mail.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23834<dl>
835<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23836<a href="git-archimport.html">git-archimport(1)</a>
837</dt>
838<dd>
839<p>
Junio C Hamano7c73c662007-01-19 00:37:50840 Import an Arch repository into git.
Junio C Hamano1a4e8412005-12-27 08:17:23841</p>
842</dd>
843<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23844<a href="git-cvsexportcommit.html">git-cvsexportcommit(1)</a>
845</dt>
846<dd>
847<p>
848 Export a single commit to a CVS checkout.
849</p>
850</dd>
851<dt>
Junio C Hamano7c73c662007-01-19 00:37:50852<a href="git-cvsimport.html">git-cvsimport(1)</a>
853</dt>
854<dd>
855<p>
856 Salvage your data out of another SCM people love to hate.
857</p>
858</dd>
859<dt>
Junio C Hamano54559c82006-04-13 07:45:12860<a href="git-cvsserver.html">git-cvsserver(1)</a>
861</dt>
862<dd>
863<p>
864 A CVS server emulator for git.
865</p>
866</dd>
867<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50868<a href="git-imap-send.html">git-imap-send(1)</a>
Junio C Hamano52299462006-12-28 00:59:38869</dt>
870<dd>
871<p>
Junio C Hamano4ad294b2007-01-20 02:22:50872 Dump a mailbox from stdin into an imap folder.
Junio C Hamano1a4e8412005-12-27 08:17:23873</p>
874</dd>
875<dt>
Junio C Hamano33db4372006-06-07 19:51:45876<a href="git-quiltimport.html">git-quiltimport(1)</a>
877</dt>
878<dd>
879<p>
880 Applies a quilt patchset onto the current branch.
881</p>
882</dd>
883<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50884<a href="git-request-pull.html">git-request-pull(1)</a>
Junio C Hamano74640642006-12-27 10:59:55885</dt>
886<dd>
887<p>
Junio C Hamano4ad294b2007-01-20 02:22:50888 Generates a summary of pending changes.
Junio C Hamano74640642006-12-27 10:59:55889</p>
890</dd>
891<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50892<a href="git-send-email.html">git-send-email(1)</a>
Junio C Hamano1a4e8412005-12-27 08:17:23893</dt>
894<dd>
895<p>
Junio C Hamano4ad294b2007-01-20 02:22:50896 Send a collection of patches as emails.
Junio C Hamano7c73c662007-01-19 00:37:50897</p>
898</dd>
899<dt>
Junio C Hamanob518f452006-08-04 00:18:06900<a href="git-svn.html">git-svn(1)</a>
901</dt>
902<dd>
903<p>
904 Bidirectional operation between a single Subversion branch and git.
905</p>
906</dd>
907<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23908<a href="git-svnimport.html">git-svnimport(1)</a>
909</dt>
910<dd>
911<p>
912 Import a SVN repository into git.
913</p>
914</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23915</dl>
916</div>
Junio C Hamanob19b4f02006-10-29 20:47:22917<h2>Low-level commands (plumbing)</h2>
918<div class="sectionbody">
919<p>Although git includes its
920own porcelain layer, its low-level commands are sufficient to support
921development of alternative porcelains. Developers of such porcelains
922might start by reading about <a href="git-update-index.html">git-update-index(1)</a> and
923<a href="git-read-tree.html">git-read-tree(1)</a>.</p>
Junio C Hamano4ad294b2007-01-20 02:22:50924<p>The interface (input, output, set of options and the semantics)
925to these low-level commands are meant to be a lot more stable
926than Porcelain level commands, because these commands are
927primarily for scripted use. The interface to Porcelain commands
928on the other hand are subject to change in order to improve the
929end user experience.</p>
930<p>The following description divides
931the low-level commands into commands that manipulate objects (in
Junio C Hamanob19b4f02006-10-29 20:47:22932the repository, index, and working tree), commands that interrogate and
933compare objects, and commands that move objects and references between
934repositories.</p>
935<h3>Manipulation commands</h3>
936<dl>
937<dt>
938<a href="git-apply.html">git-apply(1)</a>
939</dt>
940<dd>
941<p>
Junio C Hamano7c73c662007-01-19 00:37:50942 Apply a patch on a git index file and a working tree.
Junio C Hamanob19b4f02006-10-29 20:47:22943</p>
944</dd>
945<dt>
946<a href="git-checkout-index.html">git-checkout-index(1)</a>
947</dt>
948<dd>
949<p>
950 Copy files from the index to the working tree.
951</p>
952</dd>
953<dt>
954<a href="git-commit-tree.html">git-commit-tree(1)</a>
955</dt>
956<dd>
957<p>
Junio C Hamano7c73c662007-01-19 00:37:50958 Create a new commit object.
Junio C Hamanob19b4f02006-10-29 20:47:22959</p>
960</dd>
961<dt>
962<a href="git-hash-object.html">git-hash-object(1)</a>
963</dt>
964<dd>
965<p>
Junio C Hamano7c73c662007-01-19 00:37:50966 Compute object ID and optionally creates a blob from a file.
Junio C Hamanob19b4f02006-10-29 20:47:22967</p>
968</dd>
969<dt>
970<a href="git-index-pack.html">git-index-pack(1)</a>
971</dt>
972<dd>
973<p>
Junio C Hamano7c73c662007-01-19 00:37:50974 Build pack index file for an existing packed archive.
Junio C Hamanob19b4f02006-10-29 20:47:22975</p>
976</dd>
977<dt>
Junio C Hamano1de7bc62006-12-17 19:31:54978<a href="git-merge-file.html">git-merge-file(1)</a>
979</dt>
980<dd>
981<p>
Junio C Hamano7c73c662007-01-19 00:37:50982 Run a three-way file merge.
Junio C Hamano1de7bc62006-12-17 19:31:54983</p>
984</dd>
985<dt>
Junio C Hamanob19b4f02006-10-29 20:47:22986<a href="git-merge-index.html">git-merge-index(1)</a>
987</dt>
988<dd>
989<p>
Junio C Hamano7c73c662007-01-19 00:37:50990 Run a merge for files needing merging.
Junio C Hamanob19b4f02006-10-29 20:47:22991</p>
992</dd>
993<dt>
994<a href="git-mktag.html">git-mktag(1)</a>
995</dt>
996<dd>
997<p>
998 Creates a tag object.
999</p>
1000</dd>
1001<dt>
1002<a href="git-mktree.html">git-mktree(1)</a>
1003</dt>
1004<dd>
1005<p>
1006 Build a tree-object from ls-tree formatted text.
1007</p>
1008</dd>
1009<dt>
1010<a href="git-pack-objects.html">git-pack-objects(1)</a>
1011</dt>
1012<dd>
1013<p>
Junio C Hamano7c73c662007-01-19 00:37:501014 Create a packed archive of objects.
Junio C Hamanob19b4f02006-10-29 20:47:221015</p>
1016</dd>
1017<dt>
1018<a href="git-prune-packed.html">git-prune-packed(1)</a>
1019</dt>
1020<dd>
1021<p>
1022 Remove extra objects that are already in pack files.
1023</p>
1024</dd>
1025<dt>
1026<a href="git-read-tree.html">git-read-tree(1)</a>
1027</dt>
1028<dd>
1029<p>
1030 Reads tree information into the index.
1031</p>
1032</dd>
1033<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501034<a href="git-symbolic-ref.html">git-symbolic-ref(1)</a>
Junio C Hamanob19b4f02006-10-29 20:47:221035</dt>
1036<dd>
1037<p>
Junio C Hamano4ad294b2007-01-20 02:22:501038 Read and modify symbolic refs.
Junio C Hamanob19b4f02006-10-29 20:47:221039</p>
1040</dd>
1041<dt>
1042<a href="git-unpack-objects.html">git-unpack-objects(1)</a>
1043</dt>
1044<dd>
1045<p>
Junio C Hamano7c73c662007-01-19 00:37:501046 Unpack objects from a packed archive.
Junio C Hamanob19b4f02006-10-29 20:47:221047</p>
1048</dd>
1049<dt>
1050<a href="git-update-index.html">git-update-index(1)</a>
1051</dt>
1052<dd>
1053<p>
Junio C Hamano7c73c662007-01-19 00:37:501054 Register file contents in the working tree to the index.
Junio C Hamanob19b4f02006-10-29 20:47:221055</p>
1056</dd>
1057<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501058<a href="git-update-ref.html">git-update-ref(1)</a>
1059</dt>
1060<dd>
1061<p>
1062 Update the object name stored in a ref safely.
1063</p>
1064</dd>
1065<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221066<a href="git-write-tree.html">git-write-tree(1)</a>
1067</dt>
1068<dd>
1069<p>
Junio C Hamano7c73c662007-01-19 00:37:501070 Create a tree object from the current index.
Junio C Hamanob19b4f02006-10-29 20:47:221071</p>
1072</dd>
1073</dl>
1074<h3>Interrogation commands</h3>
1075<dl>
1076<dt>
1077<a href="git-cat-file.html">git-cat-file(1)</a>
1078</dt>
1079<dd>
1080<p>
1081 Provide content or type/size information for repository objects.
1082</p>
1083</dd>
1084<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221085<a href="git-diff-files.html">git-diff-files(1)</a>
1086</dt>
1087<dd>
1088<p>
1089 Compares files in the working tree and the index.
1090</p>
1091</dd>
1092<dt>
Junio C Hamano7c73c662007-01-19 00:37:501093<a href="git-diff-index.html">git-diff-index(1)</a>
1094</dt>
1095<dd>
1096<p>
1097 Compares content and mode of blobs between the index and repository.
1098</p>
1099</dd>
1100<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221101<a href="git-diff-stages.html">git-diff-stages(1)</a>
1102</dt>
1103<dd>
1104<p>
Junio C Hamano7c73c662007-01-19 00:37:501105 Compares two merge stages in the index.
Junio C Hamanob19b4f02006-10-29 20:47:221106</p>
1107</dd>
1108<dt>
1109<a href="git-diff-tree.html">git-diff-tree(1)</a>
1110</dt>
1111<dd>
1112<p>
1113 Compares the content and mode of blobs found via two tree objects.
1114</p>
1115</dd>
1116<dt>
1117<a href="git-for-each-ref.html">git-for-each-ref(1)</a>
1118</dt>
1119<dd>
1120<p>
1121 Output information on each ref.
1122</p>
1123</dd>
1124<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221125<a href="git-ls-files.html">git-ls-files(1)</a>
1126</dt>
1127<dd>
1128<p>
Junio C Hamano7c73c662007-01-19 00:37:501129 Show information about files in the index and the working tree.
Junio C Hamanob19b4f02006-10-29 20:47:221130</p>
1131</dd>
1132<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501133<a href="git-ls-remote.html">git-ls-remote(1)</a>
1134</dt>
1135<dd>
1136<p>
1137 List references in a remote repository.
1138</p>
1139</dd>
1140<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221141<a href="git-ls-tree.html">git-ls-tree(1)</a>
1142</dt>
1143<dd>
1144<p>
Junio C Hamano7c73c662007-01-19 00:37:501145 List the contents of a tree object.
Junio C Hamanob19b4f02006-10-29 20:47:221146</p>
1147</dd>
1148<dt>
1149<a href="git-merge-base.html">git-merge-base(1)</a>
1150</dt>
1151<dd>
1152<p>
Junio C Hamano7c73c662007-01-19 00:37:501153 Find as good common ancestors as possible for a merge.
Junio C Hamanob19b4f02006-10-29 20:47:221154</p>
1155</dd>
1156<dt>
1157<a href="git-name-rev.html">git-name-rev(1)</a>
1158</dt>
1159<dd>
1160<p>
1161 Find symbolic names for given revs.
1162</p>
1163</dd>
1164<dt>
1165<a href="git-pack-redundant.html">git-pack-redundant(1)</a>
1166</dt>
1167<dd>
1168<p>
1169 Find redundant pack files.
1170</p>
1171</dd>
1172<dt>
1173<a href="git-rev-list.html">git-rev-list(1)</a>
1174</dt>
1175<dd>
1176<p>
1177 Lists commit objects in reverse chronological order.
1178</p>
1179</dd>
1180<dt>
1181<a href="git-show-index.html">git-show-index(1)</a>
1182</dt>
1183<dd>
1184<p>
Junio C Hamano7c73c662007-01-19 00:37:501185 Show packed archive index.
Junio C Hamanob19b4f02006-10-29 20:47:221186</p>
1187</dd>
1188<dt>
Junio C Hamanod8c9d432006-11-07 07:19:131189<a href="git-show-ref.html">git-show-ref(1)</a>
1190</dt>
1191<dd>
1192<p>
1193 List references in a local repository.
1194</p>
1195</dd>
1196<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221197<a href="git-tar-tree.html">git-tar-tree(1)</a>
1198</dt>
1199<dd>
1200<p>
Junio C Hamano7c73c662007-01-19 00:37:501201 Create a tar archive of the files in the named tree object.
Junio C Hamanob19b4f02006-10-29 20:47:221202</p>
1203</dd>
1204<dt>
1205<a href="git-unpack-file.html">git-unpack-file(1)</a>
1206</dt>
1207<dd>
1208<p>
1209 Creates a temporary file with a blob's contents.
1210</p>
1211</dd>
1212<dt>
1213<a href="git-var.html">git-var(1)</a>
1214</dt>
1215<dd>
1216<p>
Junio C Hamano7c73c662007-01-19 00:37:501217 Show a git logical variable.
Junio C Hamanob19b4f02006-10-29 20:47:221218</p>
1219</dd>
1220<dt>
1221<a href="git-verify-pack.html">git-verify-pack(1)</a>
1222</dt>
1223<dd>
1224<p>
Junio C Hamano7c73c662007-01-19 00:37:501225 Validate packed git archive files.
Junio C Hamanob19b4f02006-10-29 20:47:221226</p>
1227</dd>
1228</dl>
1229<p>In general, the interrogate commands do not touch the files in
1230the working tree.</p>
1231<h3>Synching repositories</h3>
1232<dl>
1233<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501234<a href="git-daemon.html">git-daemon(1)</a>
1235</dt>
1236<dd>
1237<p>
1238 A really simple server for git repositories.
1239</p>
1240</dd>
1241<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221242<a href="git-fetch-pack.html">git-fetch-pack(1)</a>
1243</dt>
1244<dd>
1245<p>
Junio C Hamano7c73c662007-01-19 00:37:501246 Receive missing objects from another repository.
Junio C Hamanob19b4f02006-10-29 20:47:221247</p>
1248</dd>
1249<dt>
Junio C Hamano7c73c662007-01-19 00:37:501250<a href="git-local-fetch.html">git-local-fetch(1)</a>
1251</dt>
1252<dd>
1253<p>
1254 Duplicate another git repository on a local system.
1255</p>
1256</dd>
1257<dt>
Junio C Hamano7c73c662007-01-19 00:37:501258<a href="git-send-pack.html">git-send-pack(1)</a>
1259</dt>
1260<dd>
1261<p>
Junio C Hamanoee1e4282007-02-04 08:32:041262 Push objects over git protocol to another repository.
Junio C Hamanob19b4f02006-10-29 20:47:221263</p>
1264</dd>
1265<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221266<a href="git-ssh-fetch.html">git-ssh-fetch(1)</a>
1267</dt>
1268<dd>
1269<p>
Junio C Hamano7c73c662007-01-19 00:37:501270 Fetch from a remote repository over ssh connection.
Junio C Hamanob19b4f02006-10-29 20:47:221271</p>
1272</dd>
1273<dt>
1274<a href="git-ssh-upload.html">git-ssh-upload(1)</a>
1275</dt>
1276<dd>
1277<p>
Junio C Hamano7c73c662007-01-19 00:37:501278 Push to a remote repository over ssh connection.
Junio C Hamanob19b4f02006-10-29 20:47:221279</p>
1280</dd>
1281<dt>
1282<a href="git-update-server-info.html">git-update-server-info(1)</a>
1283</dt>
1284<dd>
1285<p>
Junio C Hamano7c73c662007-01-19 00:37:501286 Update auxiliary info file to help dumb servers.
Junio C Hamanob19b4f02006-10-29 20:47:221287</p>
1288</dd>
Junio C Hamano4ad294b2007-01-20 02:22:501289</dl>
1290<p>The following are helper programs used by the above; end users
1291typically do not use them directly.</p>
1292<dl>
1293<dt>
1294<a href="git-http-fetch.html">git-http-fetch(1)</a>
1295</dt>
1296<dd>
1297<p>
1298 Download from a remote git repository via HTTP.
1299</p>
1300</dd>
1301<dt>
1302<a href="git-http-push.html">git-http-push(1)</a>
1303</dt>
1304<dd>
1305<p>
1306 Push objects over HTTP/DAV to another repository.
1307</p>
1308</dd>
1309<dt>
1310<a href="git-parse-remote.html">git-parse-remote(1)</a>
1311</dt>
1312<dd>
1313<p>
1314 Routines to help parsing remote repository access parameters.
1315</p>
1316</dd>
1317<dt>
1318<a href="git-receive-pack.html">git-receive-pack(1)</a>
1319</dt>
1320<dd>
1321<p>
1322 Receive what is pushed into the repository.
1323</p>
1324</dd>
1325<dt>
1326<a href="git-shell.html">git-shell(1)</a>
1327</dt>
1328<dd>
1329<p>
1330 Restricted login shell for GIT-only SSH access.
1331</p>
1332</dd>
Junio C Hamanob19b4f02006-10-29 20:47:221333<dt>
1334<a href="git-upload-archive.html">git-upload-archive(1)</a>
1335</dt>
1336<dd>
1337<p>
Junio C Hamano7c73c662007-01-19 00:37:501338 Send archive back to git-archive.
Junio C Hamanob19b4f02006-10-29 20:47:221339</p>
1340</dd>
1341<dt>
1342<a href="git-upload-pack.html">git-upload-pack(1)</a>
1343</dt>
1344<dd>
1345<p>
Junio C Hamano7c73c662007-01-19 00:37:501346 Send objects packed back to git-fetch-pack.
Junio C Hamanob19b4f02006-10-29 20:47:221347</p>
1348</dd>
1349</dl>
Junio C Hamano4ad294b2007-01-20 02:22:501350<h3>Internal helper commands</h3>
1351<p>These are internal helper commands used by other commands; end
1352users typically do not use them directly.</p>
1353<dl>
1354<dt>
1355<a href="git-applypatch.html">git-applypatch(1)</a>
1356</dt>
1357<dd>
1358<p>
1359 Apply one patch extracted from an e-mail.
1360</p>
1361</dd>
1362<dt>
1363<a href="git-check-ref-format.html">git-check-ref-format(1)</a>
1364</dt>
1365<dd>
1366<p>
1367 Make sure ref name is well formed.
1368</p>
1369</dd>
1370<dt>
1371<a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>
1372</dt>
1373<dd>
1374<p>
1375 Produce a merge commit message.
1376</p>
1377</dd>
1378<dt>
1379<a href="git-mailinfo.html">git-mailinfo(1)</a>
1380</dt>
1381<dd>
1382<p>
1383 Extracts patch and authorship from a single e-mail message.
1384</p>
1385</dd>
1386<dt>
1387<a href="git-mailsplit.html">git-mailsplit(1)</a>
1388</dt>
1389<dd>
1390<p>
1391 Simple UNIX mbox splitter program.
1392</p>
1393</dd>
1394<dt>
1395<a href="git-merge-one-file.html">git-merge-one-file(1)</a>
1396</dt>
1397<dd>
1398<p>
1399 The standard helper program to use with git-merge-index.
1400</p>
1401</dd>
1402<dt>
1403<a href="git-patch-id.html">git-patch-id(1)</a>
1404</dt>
1405<dd>
1406<p>
1407 Compute unique ID for a patch.
1408</p>
1409</dd>
1410<dt>
1411<a href="git-peek-remote.html">git-peek-remote(1)</a>
1412</dt>
1413<dd>
1414<p>
1415 List the references in a remote repository.
1416</p>
1417</dd>
1418<dt>
1419<a href="git-sh-setup.html">git-sh-setup(1)</a>
1420</dt>
1421<dd>
1422<p>
1423 Common git shell script setup code.
1424</p>
1425</dd>
1426<dt>
1427<a href="git-stripspace.html">git-stripspace(1)</a>
1428</dt>
1429<dd>
1430<p>
1431 Filter out empty lines.
1432</p>
1433</dd>
1434</dl>
Junio C Hamanob19b4f02006-10-29 20:47:221435</div>
Junio C Hamano1a4e8412005-12-27 08:17:231436<h2>Configuration Mechanism</h2>
1437<div class="sectionbody">
1438<p>Starting from 0.99.9 (actually mid 0.99.8.GIT), <tt>.git/config</tt> file
1439is used to hold per-repository configuration options. It is a
Junio C Hamano51c2ab02006-07-09 20:38:541440simple text file modeled after <tt>.ini</tt> format familiar to some
Junio C Hamano1a4e8412005-12-27 08:17:231441people. Here is an example:</p>
1442<div class="listingblock">
1443<div class="content">
1444<pre><tt>#
1445# A '#' or ';' character indicates a comment.
1446#
1447
1448; core variables
1449[core]
1450 ; Don't trust file modes
1451 filemode = false
1452
1453; user identity
1454[user]
1455 name = "Junio C Hamano"
1456 email = "junkio@twinsun.com"
1457</tt></pre>
1458</div></div>
1459<p>Various commands read from the configuration file and adjust
1460their operation accordingly.</p>
1461</div>
1462<h2>Identifier Terminology</h2>
1463<div class="sectionbody">
1464<dl>
1465<dt>
1466&lt;object&gt;
1467</dt>
1468<dd>
1469<p>
1470 Indicates the object name for any type of object.
1471</p>
1472</dd>
1473<dt>
1474&lt;blob&gt;
1475</dt>
1476<dd>
1477<p>
1478 Indicates a blob object name.
1479</p>
1480</dd>
1481<dt>
1482&lt;tree&gt;
1483</dt>
1484<dd>
1485<p>
1486 Indicates a tree object name.
1487</p>
1488</dd>
1489<dt>
1490&lt;commit&gt;
1491</dt>
1492<dd>
1493<p>
1494 Indicates a commit object name.
1495</p>
1496</dd>
1497<dt>
1498&lt;tree-ish&gt;
1499</dt>
1500<dd>
1501<p>
1502 Indicates a tree, commit or tag object name. A
1503 command that takes a &lt;tree-ish&gt; argument ultimately wants to
1504 operate on a &lt;tree&gt; object but automatically dereferences
1505 &lt;commit&gt; and &lt;tag&gt; objects that point at a &lt;tree&gt;.
1506</p>
1507</dd>
1508<dt>
1509&lt;type&gt;
1510</dt>
1511<dd>
1512<p>
1513 Indicates that an object type is required.
1514 Currently one of: <tt>blob</tt>, <tt>tree</tt>, <tt>commit</tt>, or <tt>tag</tt>.
1515</p>
1516</dd>
1517<dt>
1518&lt;file&gt;
1519</dt>
1520<dd>
1521<p>
1522 Indicates a filename - almost always relative to the
1523 root of the tree structure <tt>GIT_INDEX_FILE</tt> describes.
1524</p>
1525</dd>
1526</dl>
1527</div>
1528<h2>Symbolic Identifiers</h2>
1529<div class="sectionbody">
1530<p>Any git command accepting any &lt;object&gt; can also use the following
1531symbolic notation:</p>
1532<dl>
1533<dt>
1534HEAD
1535</dt>
1536<dd>
1537<p>
1538 indicates the head of the current branch (i.e. the
1539 contents of <tt>$GIT_DIR/HEAD</tt>).
1540</p>
1541</dd>
1542<dt>
1543&lt;tag&gt;
1544</dt>
1545<dd>
1546<p>
1547 a valid tag <em>name</em>
1548 (i.e. the contents of <tt>$GIT_DIR/refs/tags/&lt;tag&gt;</tt>).
1549</p>
1550</dd>
1551<dt>
1552&lt;head&gt;
1553</dt>
1554<dd>
1555<p>
1556 a valid head <em>name</em>
1557 (i.e. the contents of <tt>$GIT_DIR/refs/heads/&lt;head&gt;</tt>).
1558</p>
1559</dd>
Junio C Hamano1a4e8412005-12-27 08:17:231560</dl>
Junio C Hamanoff4b4312006-10-25 22:55:311561<p>For a more complete list of ways to spell object names, see
1562"SPECIFYING REVISIONS" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231563</div>
1564<h2>File/Directory Structure</h2>
1565<div class="sectionbody">
1566<p>Please see <a href="repository-layout.html">repository layout</a> document.</p>
Junio C Hamano818f7d62006-03-26 01:49:301567<p>Read <a href="hooks.html">hooks</a> for more details about each hook.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231568<p>Higher level SCMs may provide and manage additional information in the
1569<tt>$GIT_DIR</tt>.</p>
1570</div>
1571<h2>Terminology</h2>
1572<div class="sectionbody">
1573<p>Please see <a href="glossary.html">glossary</a> document.</p>
1574</div>
1575<h2>Environment Variables</h2>
1576<div class="sectionbody">
1577<p>Various git commands use the following environment variables:</p>
1578<h3>The git Repository</h3>
1579<p>These environment variables apply to <em>all</em> core git commands. Nb: it
1580is worth noting that they may be used/overridden by SCMS sitting above
1581git so take care if using Cogito etc.</p>
1582<dl>
1583<dt>
1584<em>GIT_INDEX_FILE</em>
1585</dt>
1586<dd>
1587<p>
1588 This environment allows the specification of an alternate
1589 index file. If not specified, the default of <tt>$GIT_DIR/index</tt>
1590 is used.
1591</p>
1592</dd>
1593<dt>
1594<em>GIT_OBJECT_DIRECTORY</em>
1595</dt>
1596<dd>
1597<p>
1598 If the object storage directory is specified via this
1599 environment variable then the sha1 directories are created
1600 underneath - otherwise the default <tt>$GIT_DIR/objects</tt>
1601 directory is used.
1602</p>
1603</dd>
1604<dt>
1605<em>GIT_ALTERNATE_OBJECT_DIRECTORIES</em>
1606</dt>
1607<dd>
1608<p>
1609 Due to the immutable nature of git objects, old objects can be
1610 archived into shared, read-only directories. This variable
1611 specifies a ":" separated list of git object directories which
1612 can be used to search for git objects. New objects will not be
1613 written to these directories.
1614</p>
1615</dd>
1616<dt>
1617<em>GIT_DIR</em>
1618</dt>
1619<dd>
1620<p>
1621 If the <em>GIT_DIR</em> environment variable is set then it
1622 specifies a path to use instead of the default <tt>.git</tt>
1623 for the base of the repository.
1624</p>
1625</dd>
1626</dl>
1627<h3>git Commits</h3>
1628<dl>
1629<dt>
1630<em>GIT_AUTHOR_NAME</em>
1631</dt>
1632<dt>
1633<em>GIT_AUTHOR_EMAIL</em>
1634</dt>
1635<dt>
1636<em>GIT_AUTHOR_DATE</em>
1637</dt>
1638<dt>
1639<em>GIT_COMMITTER_NAME</em>
1640</dt>
1641<dt>
1642<em>GIT_COMMITTER_EMAIL</em>
1643</dt>
1644<dd>
1645<p>
1646 see <a href="git-commit-tree.html">git-commit-tree(1)</a>
1647</p>
1648</dd>
1649</dl>
1650<h3>git Diffs</h3>
1651<dl>
1652<dt>
1653<em>GIT_DIFF_OPTS</em>
1654</dt>
Junio C Hamano1c437122006-11-28 02:22:251655<dd>
1656<p>
1657 Only valid setting is "--unified=??" or "-u??" to set the
1658 number of context lines shown when a unified diff is created.
1659 This takes precedence over any "-U" or "--unified" option
1660 value passed on the git diff command line.
1661</p>
1662</dd>
Junio C Hamano1a4e8412005-12-27 08:17:231663<dt>
1664<em>GIT_EXTERNAL_DIFF</em>
1665</dt>
1666<dd>
1667<p>
Junio C Hamano1c437122006-11-28 02:22:251668 When the environment variable <em>GIT_EXTERNAL_DIFF</em> is set, the
1669 program named by it is called, instead of the diff invocation
1670 described above. For a path that is added, removed, or modified,
1671 <em>GIT_EXTERNAL_DIFF</em> is called with 7 parameters:
Junio C Hamano1a4e8412005-12-27 08:17:231672</p>
Junio C Hamano1c437122006-11-28 02:22:251673<div class="literalblock">
1674<div class="content">
1675<pre><tt>path old-file old-hex old-mode new-file new-hex new-mode</tt></pre>
1676</div></div>
1677<p>where:</p>
1678<div class="hlist"><table>
1679<tr>
1680<td class="hlist1">
1681&lt;old|new&gt;-file
1682</td>
1683<td class="hlist2">
1684are files GIT_EXTERNAL_DIFF can use to read the
1685 contents of &lt;old|new&gt;,
1686</td>
1687</tr>
1688<tr>
1689<td class="hlist1">
1690&lt;old|new&gt;-hex
1691</td>
1692<td class="hlist2">
1693are the 40-hexdigit SHA1 hashes,
1694</td>
1695</tr>
1696<tr>
1697<td class="hlist1">
1698&lt;old|new&gt;-mode
1699</td>
1700<td class="hlist2">
1701are the octal representation of the file modes.
1702</td>
1703</tr>
1704</table></div>
1705<p>The file parameters can point at the user's working file
1706(e.g. <tt>new-file</tt> in "git-diff-files"), <tt>/dev/null</tt> (e.g. <tt>old-file</tt>
1707when a new file is added), or a temporary file (e.g. <tt>old-file</tt> in the
1708index). <em>GIT_EXTERNAL_DIFF</em> should not worry about unlinking the
1709temporary file --- it is removed when <em>GIT_EXTERNAL_DIFF</em> exits.</p>
1710<p>For a path that is unmerged, <em>GIT_EXTERNAL_DIFF</em> is called with 1
1711parameter, &lt;path&gt;.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231712</dd>
1713</dl>
Junio C Hamano7ccb9fd2006-07-15 01:38:401714<h3>other</h3>
1715<dl>
1716<dt>
Junio C Hamano85e45fa2006-08-13 07:47:411717<em>GIT_PAGER</em>
1718</dt>
1719<dd>
1720<p>
1721 This environment variable overrides <tt>$PAGER</tt>.
1722</p>
1723</dd>
1724<dt>
Junio C Hamano7ccb9fd2006-07-15 01:38:401725<em>GIT_TRACE</em>
1726</dt>
1727<dd>
1728<p>
Junio C Hamanoef4b48b2006-09-04 10:08:341729 If this variable is set to "1", "2" or "true" (comparison
1730 is case insensitive), git will print <tt>trace:</tt> messages on
Junio C Hamano7ccb9fd2006-07-15 01:38:401731 stderr telling about alias expansion, built-in command
1732 execution and external command execution.
Junio C Hamanoef4b48b2006-09-04 10:08:341733 If this variable is set to an integer value greater than 1
1734 and lower than 10 (strictly) then git will interpret this
1735 value as an open file descriptor and will try to write the
1736 trace messages into this file descriptor.
1737 Alternatively, if this variable is set to an absolute path
1738 (starting with a <em>/</em> character), git will interpret this
1739 as a file path and will try to write the trace messages
1740 into it.
Junio C Hamano7ccb9fd2006-07-15 01:38:401741</p>
1742</dd>
1743</dl>
Junio C Hamano1a4e8412005-12-27 08:17:231744</div>
1745<h2>Discussion<a id="Discussion"></a></h2>
1746<div class="sectionbody">
1747<p>"git" can mean anything, depending on your mood.</p>
1748<ul>
1749<li>
1750<p>
1751random three-letter combination that is pronounceable, and not
1752 actually used by any common UNIX command. The fact that it is a
1753 mispronunciation of "get" may or may not be relevant.
1754</p>
1755</li>
1756<li>
1757<p>
1758stupid. contemptible and despicable. simple. Take your pick from the
1759 dictionary of slang.
1760</p>
1761</li>
1762<li>
1763<p>
1764"global information tracker": you're in a good mood, and it actually
1765 works for you. Angels sing, and a light suddenly fills the room.
1766</p>
1767</li>
1768<li>
1769<p>
1770"goddamn idiotic truckload of sh*t": when it breaks
1771</p>
1772</li>
1773</ul>
Junio C Hamano4f9a6052007-01-17 20:25:161774<p>This is a (not so) stupid but extremely fast directory content manager.
1775It doesn't do a whole lot at its core, but what it <em>does</em> do is track
1776directory contents efficiently.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231777<p>There are two object abstractions: the "object database", and the
1778"current directory cache" aka "index".</p>
1779<h3>The Object Database</h3>
1780<p>The object database is literally just a content-addressable collection
1781of objects. All objects are named by their content, which is
1782approximated by the SHA1 hash of the object itself. Objects may refer
1783to other objects (by referencing their SHA1 hash), and so you can
1784build up a hierarchy of objects.</p>
1785<p>All objects have a statically determined "type" aka "tag", which is
1786determined at object creation time, and which identifies the format of
1787the object (i.e. how it is used, and how it can refer to other
1788objects). There are currently four different object types: "blob",
1789"tree", "commit" and "tag".</p>
1790<p>A "blob" object cannot refer to any other object, and is, like the type
1791implies, a pure storage object containing some user data. It is used to
1792actually store the file data, i.e. a blob object is associated with some
1793particular version of some file.</p>
1794<p>A "tree" object is an object that ties one or more "blob" objects into a
1795directory structure. In addition, a tree object can refer to other tree
1796objects, thus creating a directory hierarchy.</p>
1797<p>A "commit" object ties such directory hierarchies together into
1798a DAG of revisions - each "commit" is associated with exactly one tree
1799(the directory hierarchy at the time of the commit). In addition, a
1800"commit" refers to one or more "parent" commit objects that describe the
1801history of how we arrived at that directory hierarchy.</p>
1802<p>As a special case, a commit object with no parents is called the "root"
1803object, and is the point of an initial project commit. Each project
1804must have at least one root, and while you can tie several different
1805root objects together into one project by creating a commit object which
1806has two or more separate roots as its ultimate parents, that's probably
1807just going to confuse people. So aim for the notion of "one root object
1808per project", even if git itself does not enforce that.</p>
1809<p>A "tag" object symbolically identifies and can be used to sign other
1810objects. It contains the identifier and type of another object, a
1811symbolic name (of course!) and, optionally, a signature.</p>
1812<p>Regardless of object type, all objects share the following
1813characteristics: they are all deflated with zlib, and have a header
1814that not only specifies their type, but also provides size information
1815about the data in the object. It's worth noting that the SHA1 hash
1816that is used to name the object is the hash of the original data
1817plus this header, so <tt>sha1sum</tt> <em>file</em> does not match the object name
1818for <em>file</em>.
1819(Historical note: in the dawn of the age of git the hash
1820was the sha1 of the <em>compressed</em> object.)</p>
1821<p>As a result, the general consistency of an object can always be tested
1822independently of the contents or the type of the object: all objects can
1823be validated by verifying that (a) their hashes match the content of the
1824file and (b) the object successfully inflates to a stream of bytes that
1825forms a sequence of &lt;ascii type without space&gt; + &lt;space&gt; + &lt;ascii decimal
1826size&gt; + &lt;byte\0&gt; + &lt;binary object data&gt;.</p>
1827<p>The structured objects can further have their structure and
1828connectivity to other objects verified. This is generally done with
Junio C Hamano7ad22dc2007-01-29 02:55:481829the <tt>git-fsck</tt> program, which generates a full dependency graph
Junio C Hamano1a4e8412005-12-27 08:17:231830of all objects, and verifies their internal consistency (in addition
1831to just verifying their superficial consistency through the hash).</p>
1832<p>The object types in some more detail:</p>
1833<h3>Blob Object</h3>
1834<p>A "blob" object is nothing but a binary blob of data, and doesn't
1835refer to anything else. There is no signature or any other
1836verification of the data, so while the object is consistent (it <em>is</em>
1837indexed by its sha1 hash, so the data itself is certainly correct), it
1838has absolutely no other attributes. No name associations, no
1839permissions. It is purely a blob of data (i.e. normally "file
1840contents").</p>
1841<p>In particular, since the blob is entirely defined by its data, if two
1842files in a directory tree (or in multiple different versions of the
1843repository) have the same contents, they will share the same blob
1844object. The object is totally independent of its location in the
1845directory tree, and renaming a file does not change the object that
1846file is associated with in any way.</p>
1847<p>A blob is typically created when <a href="git-update-index.html">git-update-index(1)</a>
1848is run, and its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>.</p>
1849<h3>Tree Object</h3>
1850<p>The next hierarchical object type is the "tree" object. A tree object
1851is a list of mode/name/blob data, sorted by name. Alternatively, the
1852mode data may specify a directory mode, in which case instead of
1853naming a blob, that name is associated with another TREE object.</p>
1854<p>Like the "blob" object, a tree object is uniquely determined by the
1855set contents, and so two separate but identical trees will always
1856share the exact same object. This is true at all levels, i.e. it's
1857true for a "leaf" tree (which does not refer to any other trees, only
1858blobs) as well as for a whole subdirectory.</p>
1859<p>For that reason a "tree" object is just a pure data abstraction: it
1860has no history, no signatures, no verification of validity, except
1861that since the contents are again protected by the hash itself, we can
1862trust that the tree is immutable and its contents never change.</p>
1863<p>So you can trust the contents of a tree to be valid, the same way you
1864can trust the contents of a blob, but you don't know where those
1865contents <em>came</em> from.</p>
1866<p>Side note on trees: since a "tree" object is a sorted list of
1867"filename+content", you can create a diff between two trees without
1868actually having to unpack two trees. Just ignore all common parts,
1869and your diff will look right. In other words, you can effectively
1870(and efficiently) tell the difference between any two random trees by
1871O(n) where "n" is the size of the difference, rather than the size of
1872the tree.</p>
1873<p>Side note 2 on trees: since the name of a "blob" depends entirely and
1874exclusively on its contents (i.e. there are no names or permissions
1875involved), you can see trivial renames or permission changes by
1876noticing that the blob stayed the same. However, renames with data
1877changes need a smarter "diff" implementation.</p>
1878<p>A tree is created with <a href="git-write-tree.html">git-write-tree(1)</a> and
1879its data can be accessed by <a href="git-ls-tree.html">git-ls-tree(1)</a>.
1880Two trees can be compared with <a href="git-diff-tree.html">git-diff-tree(1)</a>.</p>
1881<h3>Commit Object</h3>
1882<p>The "commit" object is an object that introduces the notion of
1883history into the picture. In contrast to the other objects, it
1884doesn't just describe the physical state of a tree, it describes how
1885we got there, and why.</p>
1886<p>A "commit" is defined by the tree-object that it results in, the
1887parent commits (zero, one or more) that led up to that point, and a
1888comment on what happened. Again, a commit is not trusted per se:
1889the contents are well-defined and "safe" due to the cryptographically
1890strong signatures at all levels, but there is no reason to believe
1891that the tree is "good" or that the merge information makes sense.
1892The parents do not have to actually have any relationship with the
1893result, for example.</p>
1894<p>Note on commits: unlike real SCM's, commits do not contain
1895rename information or file mode change information. All of that is
1896implicit in the trees involved (the result tree, and the result trees
1897of the parents), and describing that makes no sense in this idiotic
1898file manager.</p>
1899<p>A commit is created with <a href="git-commit-tree.html">git-commit-tree(1)</a> and
1900its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>.</p>
1901<h3>Trust</h3>
1902<p>An aside on the notion of "trust". Trust is really outside the scope
1903of "git", but it's worth noting a few things. First off, since
1904everything is hashed with SHA1, you <em>can</em> trust that an object is
1905intact and has not been messed with by external sources. So the name
1906of an object uniquely identifies a known state - just not a state that
1907you may want to trust.</p>
1908<p>Furthermore, since the SHA1 signature of a commit refers to the
1909SHA1 signatures of the tree it is associated with and the signatures
1910of the parent, a single named commit specifies uniquely a whole set
1911of history, with full contents. You can't later fake any step of the
1912way once you have the name of a commit.</p>
1913<p>So to introduce some real trust in the system, the only thing you need
1914to do is to digitally sign just <em>one</em> special note, which includes the
1915name of a top-level commit. Your digital signature shows others
1916that you trust that commit, and the immutability of the history of
1917commits tells others that they can trust the whole history.</p>
1918<p>In other words, you can easily validate a whole archive by just
1919sending out a single email that tells the people the name (SHA1 hash)
1920of the top commit, and digitally sign that email using something
1921like GPG/PGP.</p>
1922<p>To assist in this, git also provides the tag object&#8230;</p>
1923<h3>Tag Object</h3>
1924<p>Git provides the "tag" object to simplify creating, managing and
1925exchanging symbolic and signed tokens. The "tag" object at its
1926simplest simply symbolically identifies another object by containing
1927the sha1, type and symbolic name.</p>
1928<p>However it can optionally contain additional signature information
1929(which git doesn't care about as long as there's less than 8k of
1930it). This can then be verified externally to git.</p>
1931<p>Note that despite the tag features, "git" itself only handles content
1932integrity; the trust framework (and signature provision and
1933verification) has to come from outside.</p>
1934<p>A tag is created with <a href="git-mktag.html">git-mktag(1)</a>,
1935its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>,
1936and the signature can be verified by
1937<a href="git-verify-tag.html">git-verify-tag(1)</a>.</p>
1938</div>
1939<h2>The "index" aka "Current Directory Cache"</h2>
1940<div class="sectionbody">
1941<p>The index is a simple binary file, which contains an efficient
1942representation of a virtual directory content at some random time. It
1943does so by a simple array that associates a set of names, dates,
1944permissions and content (aka "blob") objects together. The cache is
1945always kept ordered by name, and names are unique (with a few very
1946specific rules) at any point in time, but the cache has no long-term
1947meaning, and can be partially updated at any time.</p>
1948<p>In particular, the index certainly does not need to be consistent with
1949the current directory contents (in fact, most operations will depend on
1950different ways to make the index <em>not</em> be consistent with the directory
1951hierarchy), but it has three very important attributes:</p>
1952<p><em>(a) it can re-generate the full state it caches (not just the
1953directory structure: it contains pointers to the "blob" objects so
1954that it can regenerate the data too)</em></p>
1955<p>As a special case, there is a clear and unambiguous one-way mapping
1956from a current directory cache to a "tree object", which can be
1957efficiently created from just the current directory cache without
1958actually looking at any other data. So a directory cache at any one
1959time uniquely specifies one and only one "tree" object (but has
1960additional data to make it easy to match up that tree object with what
1961has happened in the directory)</p>
1962<p><em>(b) it has efficient methods for finding inconsistencies between that
1963cached state ("tree object waiting to be instantiated") and the
1964current state.</em></p>
1965<p><em>(c) it can additionally efficiently represent information about merge
1966conflicts between different tree objects, allowing each pathname to be
1967associated with sufficient information about the trees involved that
1968you can create a three-way merge between them.</em></p>
1969<p>Those are the three ONLY things that the directory cache does. It's a
1970cache, and the normal operation is to re-generate it completely from a
1971known tree object, or update/compare it with a live tree that is being
1972developed. If you blow the directory cache away entirely, you generally
1973haven't lost any information as long as you have the name of the tree
1974that it described.</p>
1975<p>At the same time, the index is at the same time also the
1976staging area for creating new trees, and creating a new tree always
1977involves a controlled modification of the index file. In particular,
1978the index file can have the representation of an intermediate tree that
1979has not yet been instantiated. So the index can be thought of as a
1980write-back cache, which can contain dirty information that has not yet
1981been written back to the backing store.</p>
1982</div>
1983<h2>The Workflow</h2>
1984<div class="sectionbody">
1985<p>Generally, all "git" operations work on the index file. Some operations
1986work <strong>purely</strong> on the index file (showing the current state of the
1987index), but most operations move data to and from the index file. Either
1988from the database or from the working directory. Thus there are four
1989main combinations:</p>
1990<h3>1) working directory -&gt; index</h3>
1991<p>You update the index with information from the working directory with
1992the <a href="git-update-index.html">git-update-index(1)</a> command. You
1993generally update the index information by just specifying the filename
1994you want to update, like so:</p>
1995<div class="literalblock">
1996<div class="content">
1997<pre><tt>git-update-index filename</tt></pre>
1998</div></div>
1999<p>but to avoid common mistakes with filename globbing etc, the command
2000will not normally add totally new entries or remove old entries,
2001i.e. it will normally just update existing cache entries.</p>
2002<p>To tell git that yes, you really do realize that certain files no
2003longer exist, or that new files should be added, you
2004should use the <tt>--remove</tt> and <tt>--add</tt> flags respectively.</p>
2005<p>NOTE! A <tt>--remove</tt> flag does <em>not</em> mean that subsequent filenames will
2006necessarily be removed: if the files still exist in your directory
2007structure, the index will be updated with their new status, not
2008removed. The only thing <tt>--remove</tt> means is that update-cache will be
2009considering a removed file to be a valid thing, and if the file really
2010does not exist any more, it will update the index accordingly.</p>
2011<p>As a special case, you can also do <tt>git-update-index --refresh</tt>, which
2012will refresh the "stat" information of each index to match the current
2013stat information. It will <em>not</em> update the object status itself, and
2014it will only update the fields that are used to quickly test whether
2015an object still matches its old backing store object.</p>
2016<h3>2) index -&gt; object database</h3>
2017<p>You write your current index file to a "tree" object with the program</p>
2018<div class="literalblock">
2019<div class="content">
2020<pre><tt>git-write-tree</tt></pre>
2021</div></div>
2022<p>that doesn't come with any options - it will just write out the
2023current index into the set of tree objects that describe that state,
2024and it will return the name of the resulting top-level tree. You can
2025use that tree to re-generate the index at any time by going in the
2026other direction:</p>
2027<h3>3) object database -&gt; index</h3>
2028<p>You read a "tree" file from the object database, and use that to
2029populate (and overwrite - don't do this if your index contains any
2030unsaved state that you might want to restore later!) your current
2031index. Normal operation is just</p>
2032<div class="literalblock">
2033<div class="content">
2034<pre><tt>git-read-tree &lt;sha1 of tree&gt;</tt></pre>
2035</div></div>
2036<p>and your index file will now be equivalent to the tree that you saved
2037earlier. However, that is only your <em>index</em> file: your working
2038directory contents have not been modified.</p>
2039<h3>4) index -&gt; working directory</h3>
2040<p>You update your working directory from the index by "checking out"
2041files. This is not a very common operation, since normally you'd just
2042keep your files updated, and rather than write to your working
2043directory, you'd tell the index files about the changes in your
2044working directory (i.e. <tt>git-update-index</tt>).</p>
2045<p>However, if you decide to jump to a new version, or check out somebody
2046else's version, or just restore a previous tree, you'd populate your
2047index file with read-tree, and then you need to check out the result
2048with</p>
2049<div class="literalblock">
2050<div class="content">
2051<pre><tt>git-checkout-index filename</tt></pre>
2052</div></div>
2053<p>or, if you want to check out all of the index, use <tt>-a</tt>.</p>
2054<p>NOTE! git-checkout-index normally refuses to overwrite old files, so
2055if you have an old version of the tree already checked out, you will
2056need to use the "-f" flag (<em>before</em> the "-a" flag or the filename) to
2057<em>force</em> the checkout.</p>
2058<p>Finally, there are a few odds and ends which are not purely moving
2059from one representation to the other:</p>
2060<h3>5) Tying it all together</h3>
2061<p>To commit a tree you have instantiated with "git-write-tree", you'd
2062create a "commit" object that refers to that tree and the history
2063behind it - most notably the "parent" commits that preceded it in
2064history.</p>
2065<p>Normally a "commit" has one parent: the previous state of the tree
2066before a certain change was made. However, sometimes it can have two
2067or more parent commits, in which case we call it a "merge", due to the
2068fact that such a commit brings together ("merges") two or more
2069previous states represented by other commits.</p>
2070<p>In other words, while a "tree" represents a particular directory state
2071of a working directory, a "commit" represents that state in "time",
2072and explains how we got there.</p>
2073<p>You create a commit object by giving it the tree that describes the
2074state at the time of the commit, and a list of parents:</p>
2075<div class="literalblock">
2076<div class="content">
2077<pre><tt>git-commit-tree &lt;tree&gt; -p &lt;parent&gt; [-p &lt;parent2&gt; ..]</tt></pre>
2078</div></div>
2079<p>and then giving the reason for the commit on stdin (either through
2080redirection from a pipe or file, or by just typing it at the tty).</p>
2081<p>git-commit-tree will return the name of the object that represents
2082that commit, and you should save it away for later use. Normally,
2083you'd commit a new <tt>HEAD</tt> state, and while git doesn't care where you
2084save the note about that state, in practice we tend to just write the
2085result to the file pointed at by <tt>.git/HEAD</tt>, so that we can always see
2086what the last committed state was.</p>
2087<p>Here is an ASCII art by Jon Loeliger that illustrates how
2088various pieces fit together.</p>
2089<div class="listingblock">
2090<div class="content">
2091<pre><tt>
2092 commit-tree
2093 commit obj
2094 +----+
2095 | |
2096 | |
2097 V V
2098 +-----------+
2099 | Object DB |
2100 | Backing |
2101 | Store |
2102 +-----------+
2103 ^
2104 write-tree | |
2105 tree obj | |
2106 | | read-tree
2107 | | tree obj
2108 V
2109 +-----------+
2110 | Index |
2111 | "cache" |
2112 +-----------+
2113 update-index ^
2114 blob obj | |
2115 | |
2116 checkout-index -u | | checkout-index
2117 stat | | blob obj
2118 V
2119 +-----------+
2120 | Working |
2121 | Directory |
2122 +-----------+
2123</tt></pre>
2124</div></div>
2125<h3>6) Examining the data</h3>
2126<p>You can examine the data represented in the object database and the
2127index with various helper tools. For every object, you can use
2128<a href="git-cat-file.html">git-cat-file(1)</a> to examine details about the
2129object:</p>
2130<div class="literalblock">
2131<div class="content">
2132<pre><tt>git-cat-file -t &lt;objectname&gt;</tt></pre>
2133</div></div>
2134<p>shows the type of the object, and once you have the type (which is
2135usually implicit in where you find the object), you can use</p>
2136<div class="literalblock">
2137<div class="content">
2138<pre><tt>git-cat-file blob|tree|commit|tag &lt;objectname&gt;</tt></pre>
2139</div></div>
2140<p>to show its contents. NOTE! Trees have binary content, and as a result
2141there is a special helper for showing that content, called
2142<tt>git-ls-tree</tt>, which turns the binary content into a more easily
2143readable form.</p>
2144<p>It's especially instructive to look at "commit" objects, since those
2145tend to be small and fairly self-explanatory. In particular, if you
2146follow the convention of having the top commit name in <tt>.git/HEAD</tt>,
2147you can do</p>
2148<div class="literalblock">
2149<div class="content">
2150<pre><tt>git-cat-file commit HEAD</tt></pre>
2151</div></div>
2152<p>to see what the top commit was.</p>
2153<h3>7) Merging multiple trees</h3>
2154<p>Git helps you do a three-way merge, which you can expand to n-way by
2155repeating the merge procedure arbitrary times until you finally
2156"commit" the state. The normal situation is that you'd only do one
2157three-way merge (two parents), and commit it, but if you like to, you
2158can do multiple parents in one go.</p>
2159<p>To do a three-way merge, you need the two sets of "commit" objects
2160that you want to merge, use those to find the closest common parent (a
2161third "commit" object), and then use those commit objects to find the
2162state of the directory ("tree" object) at these points.</p>
2163<p>To get the "base" for the merge, you first look up the common parent
2164of two commits with</p>
2165<div class="literalblock">
2166<div class="content">
2167<pre><tt>git-merge-base &lt;commit1&gt; &lt;commit2&gt;</tt></pre>
2168</div></div>
2169<p>which will return you the commit they are both based on. You should
2170now look up the "tree" objects of those commits, which you can easily
2171do with (for example)</p>
2172<div class="literalblock">
2173<div class="content">
2174<pre><tt>git-cat-file commit &lt;commitname&gt; | head -1</tt></pre>
2175</div></div>
2176<p>since the tree object information is always the first line in a commit
2177object.</p>
2178<p>Once you know the three trees you are going to merge (the one
2179"original" tree, aka the common case, and the two "result" trees, aka
2180the branches you want to merge), you do a "merge" read into the
2181index. This will complain if it has to throw away your old index contents, so you should
2182make sure that you've committed those - in fact you would normally
2183always do a merge against your last commit (which should thus match
2184what you have in your current index anyway).</p>
2185<p>To do the merge, do</p>
2186<div class="literalblock">
2187<div class="content">
2188<pre><tt>git-read-tree -m -u &lt;origtree&gt; &lt;yourtree&gt; &lt;targettree&gt;</tt></pre>
2189</div></div>
2190<p>which will do all trivial merge operations for you directly in the
2191index file, and you can just write the result out with
2192<tt>git-write-tree</tt>.</p>
2193<p>Historical note. We did not have <tt>-u</tt> facility when this
2194section was first written, so we used to warn that
2195the merge is done in the index file, not in your
2196working tree, and your working tree will not match your
2197index after this step.
2198This is no longer true. The above command, thanks to <tt>-u</tt>
2199option, updates your working tree with the merge results for
2200paths that have been trivially merged.</p>
2201<h3>8) Merging multiple trees, continued</h3>
2202<p>Sadly, many merges aren't trivial. If there are files that have
2203been added.moved or removed, or if both branches have modified the
2204same file, you will be left with an index tree that contains "merge
2205entries" in it. Such an index tree can <em>NOT</em> be written out to a tree
2206object, and you will have to resolve any such merge clashes using
2207other tools before you can write out the result.</p>
2208<p>You can examine such index state with <tt>git-ls-files --unmerged</tt>
2209command. An example:</p>
2210<div class="listingblock">
2211<div class="content">
2212<pre><tt>$ git-read-tree -m $orig HEAD $target
2213$ git-ls-files --unmerged
2214100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
2215100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
2216100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c</tt></pre>
2217</div></div>
2218<p>Each line of the <tt>git-ls-files --unmerged</tt> output begins with
2219the blob mode bits, blob SHA1, <em>stage number</em>, and the
2220filename. The <em>stage number</em> is git's way to say which tree it
2221came from: stage 1 corresponds to <tt>$orig</tt> tree, stage 2 <tt>HEAD</tt>
2222tree, and stage3 <tt>$target</tt> tree.</p>
2223<p>Earlier we said that trivial merges are done inside
2224<tt>git-read-tree -m</tt>. For example, if the file did not change
2225from <tt>$orig</tt> to <tt>HEAD</tt> nor <tt>$target</tt>, or if the file changed
2226from <tt>$orig</tt> to <tt>HEAD</tt> and <tt>$orig</tt> to <tt>$target</tt> the same way,
2227obviously the final outcome is what is in <tt>HEAD</tt>. What the
2228above example shows is that file <tt>hello.c</tt> was changed from
2229<tt>$orig</tt> to <tt>HEAD</tt> and <tt>$orig</tt> to <tt>$target</tt> in a different way.
2230You could resolve this by running your favorite 3-way merge
2231program, e.g. <tt>diff3</tt> or <tt>merge</tt>, on the blob objects from
2232these three stages yourself, like this:</p>
2233<div class="listingblock">
2234<div class="content">
2235<pre><tt>$ git-cat-file blob 263414f... &gt;hello.c~1
2236$ git-cat-file blob 06fa6a2... &gt;hello.c~2
2237$ git-cat-file blob cc44c73... &gt;hello.c~3
2238$ merge hello.c~2 hello.c~1 hello.c~3</tt></pre>
2239</div></div>
2240<p>This would leave the merge result in <tt>hello.c~2</tt> file, along
2241with conflict markers if there are conflicts. After verifying
2242the merge result makes sense, you can tell git what the final
2243merge result for this file is by:</p>
2244<div class="literalblock">
2245<div class="content">
2246<pre><tt>mv -f hello.c~2 hello.c
2247git-update-index hello.c</tt></pre>
2248</div></div>
2249<p>When a path is in unmerged state, running <tt>git-update-index</tt> for
2250that path tells git to mark the path resolved.</p>
2251<p>The above is the description of a git merge at the lowest level,
2252to help you understand what conceptually happens under the hood.
2253In practice, nobody, not even git itself, uses three <tt>git-cat-file</tt>
2254for this. There is <tt>git-merge-index</tt> program that extracts the
2255stages to temporary files and calls a "merge" script on it:</p>
2256<div class="literalblock">
2257<div class="content">
2258<pre><tt>git-merge-index git-merge-one-file hello.c</tt></pre>
2259</div></div>
2260<p>and that is what higher level <tt>git resolve</tt> is implemented with.</p>
2261</div>
2262<h2>Authors</h2>
2263<div class="sectionbody">
2264<ul>
2265<li>
2266<p>
2267git's founding father is Linus Torvalds &lt;torvalds@osdl.org&gt;.
2268</p>
2269</li>
2270<li>
2271<p>
2272The current git nurse is Junio C Hamano &lt;junkio@cox.net&gt;.
2273</p>
2274</li>
2275<li>
2276<p>
2277The git potty was written by Andres Ericsson &lt;ae@op5.se&gt;.
2278</p>
2279</li>
2280<li>
2281<p>
2282General upbringing is handled by the git-list &lt;git@vger.kernel.org&gt;.
2283</p>
2284</li>
2285</ul>
2286</div>
2287<h2>Documentation</h2>
2288<div class="sectionbody">
2289<p>The documentation for git suite was started by David Greaves
2290&lt;david@dgreaves.com&gt;, and later enhanced greatly by the
2291contributors on the git-list &lt;git@vger.kernel.org&gt;.</p>
2292</div>
2293<h2>GIT</h2>
2294<div class="sectionbody">
2295<p>Part of the <a href="git.html">git(7)</a> suite</p>
2296</div>
2297<div id="footer">
2298<div id="footer-text">
Junio C Hamanodfc4ce72007-02-07 23:17:292299Last updated 07-Feb-2007 23:17:18 UTC
Junio C Hamano1a4e8412005-12-27 08:17:232300</div>
2301</div>
2302</body>
2303</html>