blob: 6af03bef2773a59c9f424b5db046237275881a81 [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
287also want to read <a href="cvs-migration.html">CVS migration</a>.</p>
Junio C Hamano33db4372006-06-07 19:51:45288<p>The COMMAND is either a name of a Git command (see below) or an alias
289as defined in the configuration file (see <a href="git-repo-config.html">git-repo-config(1)</a>).</p>
Junio C Hamano1a4e8412005-12-27 08:17:23290</div>
291<h2>OPTIONS</h2>
292<div class="sectionbody">
293<dl>
294<dt>
295--version
296</dt>
297<dd>
298<p>
Junio C Hamano01078922006-03-10 00:31:47299 Prints the git suite version that the <em>git</em> program came from.
Junio C Hamano1a4e8412005-12-27 08:17:23300</p>
301</dd>
302<dt>
303--help
304</dt>
305<dd>
306<p>
Junio C Hamano01078922006-03-10 00:31:47307 Prints the synopsis and a list of the most commonly used
308 commands. If a git command is named this option will bring up
309 the man-page for that command. If the option <em>--all</em> or <em>-a</em> is
310 given then all available commands are printed.
Junio C Hamano1a4e8412005-12-27 08:17:23311</p>
312</dd>
313<dt>
314--exec-path
315</dt>
316<dd>
317<p>
Junio C Hamano01078922006-03-10 00:31:47318 Path to wherever your core git programs are installed.
Junio C Hamano1a4e8412005-12-27 08:17:23319 This can also be controlled by setting the GIT_EXEC_PATH
320 environment variable. If no path is given <em>git</em> will print
321 the current setting and then exit.
322</p>
323</dd>
Junio C Hamanof870ef82006-07-29 09:10:13324<dt>
325-p|--paginate
326</dt>
327<dd>
328<p>
329 Pipe all output into <em>less</em> (or if set, $PAGER).
330</p>
331</dd>
332<dt>
333--git-dir=&lt;path&gt;
334</dt>
335<dd>
336<p>
337 Set the path to the repository. This can also be controlled by
338 setting the GIT_DIR environment variable.
339</p>
340</dd>
341<dt>
342--bare
343</dt>
344<dd>
345<p>
346 Same as --git-dir=<tt>pwd</tt>.
347</p>
348</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23349</dl>
350</div>
Junio C Hamanoe27fb932006-04-03 05:34:10351<h2>FURTHER DOCUMENTATION</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23352<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10353<p>See the references above to get started using git. The following is
354probably more detail than necessary for a first-time user.</p>
355<p>The <a href="#Discussion">Discussion</a> section below and the
356<a href="core-tutorial.html">Core tutorial</a> both provide introductions to the
357underlying git architecture.</p>
358<p>See also the <a href="howto-index.html">howto</a> documents for some useful
359examples.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23360</div>
Junio C Hamanoe27fb932006-04-03 05:34:10361<h2>GIT COMMANDS</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23362<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10363<p>We divide git into high level ("porcelain") commands and low level
364("plumbing") commands.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23365</div>
Junio C Hamanoe27fb932006-04-03 05:34:10366<h2>High-level commands (porcelain)</h2>
Junio C Hamano1a4e8412005-12-27 08:17:23367<div class="sectionbody">
Junio C Hamanoe27fb932006-04-03 05:34:10368<p>We separate the porcelain commands into the main commands and some
369ancillary user utilities.</p>
370<h3>Main porcelain commands</h3>
Junio C Hamano1a4e8412005-12-27 08:17:23371<dl>
372<dt>
373<a href="git-add.html">git-add(1)</a>
374</dt>
375<dd>
376<p>
Junio C Hamano7c73c662007-01-19 00:37:50377 Add file contents to the changeset to be committed next.
Junio C Hamano1a4e8412005-12-27 08:17:23378</p>
379</dd>
380<dt>
381<a href="git-am.html">git-am(1)</a>
382</dt>
383<dd>
384<p>
Junio C Hamano7c73c662007-01-19 00:37:50385 Apply a series of patches from a mailbox.
Junio C Hamano1a4e8412005-12-27 08:17:23386</p>
387</dd>
388<dt>
Junio C Hamano817abb42006-09-26 07:16:58389<a href="git-archive.html">git-archive(1)</a>
390</dt>
391<dd>
392<p>
393 Creates an archive of files from a named tree.
394</p>
395</dd>
396<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23397<a href="git-bisect.html">git-bisect(1)</a>
398</dt>
399<dd>
400<p>
401 Find the change that introduced a bug by binary search.
402</p>
403</dd>
404<dt>
405<a href="git-branch.html">git-branch(1)</a>
406</dt>
407<dd>
408<p>
Junio C Hamano7c73c662007-01-19 00:37:50409 List, create, or delete branches.
Junio C Hamano1a4e8412005-12-27 08:17:23410</p>
411</dd>
412<dt>
413<a href="git-checkout.html">git-checkout(1)</a>
414</dt>
415<dd>
416<p>
417 Checkout and switch to a branch.
418</p>
419</dd>
420<dt>
421<a href="git-cherry-pick.html">git-cherry-pick(1)</a>
422</dt>
423<dd>
424<p>
Junio C Hamano7c73c662007-01-19 00:37:50425 Apply the change introduced by an existing commit.
Junio C Hamano1a4e8412005-12-27 08:17:23426</p>
427</dd>
428<dt>
Junio C Hamano54559c82006-04-13 07:45:12429<a href="git-clean.html">git-clean(1)</a>
430</dt>
431<dd>
432<p>
433 Remove untracked files from the working tree.
434</p>
435</dd>
436<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23437<a href="git-clone.html">git-clone(1)</a>
438</dt>
439<dd>
440<p>
441 Clones a repository into a new directory.
442</p>
443</dd>
444<dt>
445<a href="git-commit.html">git-commit(1)</a>
446</dt>
447<dd>
448<p>
449 Record changes to the repository.
450</p>
451</dd>
452<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50453<a href="git-describe.html">git-describe(1)</a>
454</dt>
455<dd>
456<p>
457 Show the most recent tag that is reachable from a commit.
458</p>
459</dd>
460<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23461<a href="git-diff.html">git-diff(1)</a>
462</dt>
463<dd>
464<p>
465 Show changes between commits, commit and working tree, etc.
466</p>
467</dd>
468<dt>
469<a href="git-fetch.html">git-fetch(1)</a>
470</dt>
471<dd>
472<p>
Junio C Hamano7c73c662007-01-19 00:37:50473 Download objects and refs from another repository.
Junio C Hamano1a4e8412005-12-27 08:17:23474</p>
475</dd>
476<dt>
477<a href="git-format-patch.html">git-format-patch(1)</a>
478</dt>
479<dd>
480<p>
481 Prepare patches for e-mail submission.
482</p>
483</dd>
484<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50485<a href="git-gc.html">git-gc(1)</a>
486</dt>
487<dd>
488<p>
489 Cleanup unnecessary files and optimize the local repository.
490</p>
491</dd>
492<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23493<a href="git-grep.html">git-grep(1)</a>
494</dt>
495<dd>
496<p>
497 Print lines matching a pattern.
498</p>
499</dd>
500<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50501<a href="git-init.html">git-init(1)</a>
502</dt>
503<dd>
504<p>
505 Create an empty git repository or reinitialize an existing one.
506</p>
507</dd>
508<dt>
Junio C Hamanoeb8e3572006-09-01 08:25:07509<a href="gitk.html">gitk(1)</a>
510</dt>
511<dd>
512<p>
513 The git repository browser.
514</p>
515</dd>
516<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23517<a href="git-log.html">git-log(1)</a>
518</dt>
519<dd>
520<p>
Junio C Hamano7c73c662007-01-19 00:37:50521 Show commit logs.
Junio C Hamano1a4e8412005-12-27 08:17:23522</p>
523</dd>
524<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23525<a href="git-merge.html">git-merge(1)</a>
526</dt>
527<dd>
528<p>
Junio C Hamano7c73c662007-01-19 00:37:50529 Join two or more development histories together.
Junio C Hamano1a4e8412005-12-27 08:17:23530</p>
531</dd>
532<dt>
533<a href="git-mv.html">git-mv(1)</a>
534</dt>
535<dd>
536<p>
537 Move or rename a file, a directory, or a symlink.
538</p>
539</dd>
540<dt>
541<a href="git-pull.html">git-pull(1)</a>
542</dt>
543<dd>
544<p>
Junio C Hamano7c73c662007-01-19 00:37:50545 Fetch from and merge with another repository or a local branch.
Junio C Hamano1a4e8412005-12-27 08:17:23546</p>
547</dd>
548<dt>
549<a href="git-push.html">git-push(1)</a>
550</dt>
551<dd>
552<p>
553 Update remote refs along with associated objects.
554</p>
555</dd>
556<dt>
557<a href="git-rebase.html">git-rebase(1)</a>
558</dt>
559<dd>
560<p>
Junio C Hamano7c73c662007-01-19 00:37:50561 Forward-port local commits to the updated upstream head.
Junio C Hamano1a4e8412005-12-27 08:17:23562</p>
563</dd>
564<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23565<a href="git-reset.html">git-reset(1)</a>
566</dt>
567<dd>
568<p>
569 Reset current HEAD to the specified state.
570</p>
571</dd>
572<dt>
573<a href="git-resolve.html">git-resolve(1)</a>
574</dt>
575<dd>
576<p>
577 Merge two commits.
578</p>
579</dd>
580<dt>
581<a href="git-revert.html">git-revert(1)</a>
582</dt>
583<dd>
584<p>
585 Revert an existing commit.
586</p>
587</dd>
588<dt>
Junio C Hamano54559c82006-04-13 07:45:12589<a href="git-rm.html">git-rm(1)</a>
590</dt>
591<dd>
592<p>
593 Remove files from the working tree and from the index.
594</p>
595</dd>
596<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23597<a href="git-shortlog.html">git-shortlog(1)</a>
598</dt>
599<dd>
600<p>
Junio C Hamano7c73c662007-01-19 00:37:50601 Summarize <em>git log</em> output.
Junio C Hamano1a4e8412005-12-27 08:17:23602</p>
603</dd>
604<dt>
Junio C Hamano2b135272006-03-18 07:45:42605<a href="git-show.html">git-show(1)</a>
606</dt>
607<dd>
608<p>
Junio C Hamano7c73c662007-01-19 00:37:50609 Show various types of objects.
Junio C Hamano2b135272006-03-18 07:45:42610</p>
611</dd>
612<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23613<a href="git-status.html">git-status(1)</a>
614</dt>
615<dd>
616<p>
Junio C Hamano7c73c662007-01-19 00:37:50617 Show the working tree status.
Junio C Hamano1a4e8412005-12-27 08:17:23618</p>
619</dd>
620<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50621<a href="git-tag.html">git-tag(1)</a>
622</dt>
623<dd>
624<p>
Junio C Hamanodb450ba2007-01-21 08:57:14625 Create, list, delete or verify a tag object signed with GPG.
Junio C Hamano4ad294b2007-01-20 02:22:50626</p>
627</dd>
628</dl>
629<h3>Ancillary Commands</h3>
630<p>Manipulators:</p>
631<dl>
632<dt>
633<a href="git-convert-objects.html">git-convert-objects(1)</a>
634</dt>
635<dd>
636<p>
637 Converts old-style git repository.
638</p>
639</dd>
640<dt>
641<a href="git-lost-found.html">git-lost-found(1)</a>
642</dt>
643<dd>
644<p>
645 Recover lost refs that luckily have not yet been pruned.
646</p>
647</dd>
648<dt>
649<a href="git-pack-refs.html">git-pack-refs(1)</a>
650</dt>
651<dd>
652<p>
653 Pack heads and tags for efficient repository access.
654</p>
655</dd>
656<dt>
657<a href="git-prune.html">git-prune(1)</a>
658</dt>
659<dd>
660<p>
661 Prunes all unreachable objects from the object database.
662</p>
663</dd>
664<dt>
665<a href="git-reflog.html">git-reflog(1)</a>
666</dt>
667<dd>
668<p>
669 Manage reflog information.
670</p>
671</dd>
672<dt>
673<a href="git-relink.html">git-relink(1)</a>
674</dt>
675<dd>
676<p>
677 Hardlink common objects in local repositories.
678</p>
679</dd>
680<dt>
681<a href="git-repack.html">git-repack(1)</a>
682</dt>
683<dd>
684<p>
685 Pack unpacked objects in a repository.
686</p>
687</dd>
688<dt>
689<a href="git-repo-config.html">git-repo-config(1)</a>
690</dt>
691<dd>
692<p>
693 Get and set repository or global options.
694</p>
695</dd>
696</dl>
697<p>Interrogators:</p>
698<dl>
699<dt>
700<a href="git-annotate.html">git-annotate(1)</a>
701</dt>
702<dd>
703<p>
704 Annotate file lines with commit info.
705</p>
706</dd>
707<dt>
708<a href="git-applymbox.html">git-applymbox(1)</a>
709</dt>
710<dd>
711<p>
712 Apply a series of patches in a mailbox.
713</p>
714</dd>
715<dt>
716<a href="git-blame.html">git-blame(1)</a>
717</dt>
718<dd>
719<p>
720 Show what revision and author last modified each line of a file.
721</p>
722</dd>
723<dt>
724<a href="git-cherry.html">git-cherry(1)</a>
725</dt>
726<dd>
727<p>
728 Find commits not merged upstream.
729</p>
730</dd>
731<dt>
732<a href="git-count-objects.html">git-count-objects(1)</a>
733</dt>
734<dd>
735<p>
736 Count unpacked number of objects and their disk consumption.
737</p>
738</dd>
739<dt>
740<a href="git-fsck-objects.html">git-fsck-objects(1)</a>
741</dt>
742<dd>
743<p>
744 Verifies the connectivity and validity of the objects in the database.
745</p>
746</dd>
747<dt>
748<a href="git-get-tar-commit-id.html">git-get-tar-commit-id(1)</a>
749</dt>
750<dd>
751<p>
752 Extract commit ID from an archive created using git-tar-tree.
753</p>
754</dd>
755<dt>
756<a href="git-instaweb.html">git-instaweb(1)</a>
757</dt>
758<dd>
759<p>
760 Instantly browse your working repository in gitweb.
761</p>
762</dd>
763<dt>
764<a href="git-merge-tree.html">git-merge-tree(1)</a>
765</dt>
766<dd>
767<p>
768 Show three-way merge without touching index.
769</p>
770</dd>
771<dt>
772<a href="git-rerere.html">git-rerere(1)</a>
773</dt>
774<dd>
775<p>
776 Reuse recorded resolution of conflicted merges.
777</p>
778</dd>
779<dt>
780<a href="git-rev-parse.html">git-rev-parse(1)</a>
781</dt>
782<dd>
783<p>
784 Pick out and massage parameters.
785</p>
786</dd>
787<dt>
788<a href="git-runstatus.html">git-runstatus(1)</a>
789</dt>
790<dd>
791<p>
792 A helper for git-status and git-commit.
793</p>
794</dd>
795<dt>
796<a href="git-show-branch.html">git-show-branch(1)</a>
797</dt>
798<dd>
799<p>
800 Show branches and their commits.
801</p>
802</dd>
803<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23804<a href="git-verify-tag.html">git-verify-tag(1)</a>
805</dt>
806<dd>
807<p>
808 Check the GPG signature of tag.
809</p>
810</dd>
811<dt>
812<a href="git-whatchanged.html">git-whatchanged(1)</a>
813</dt>
814<dd>
815<p>
Junio C Hamano7c73c662007-01-19 00:37:50816 Show logs with difference each commit introduces.
Junio C Hamano1a4e8412005-12-27 08:17:23817</p>
818</dd>
819</dl>
Junio C Hamano4ad294b2007-01-20 02:22:50820<h3>Interacting with Others</h3>
821<p>These commands are to interact with foreign SCM and with other
822people via patch over e-mail.</p>
Junio C Hamano1a4e8412005-12-27 08:17:23823<dl>
824<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23825<a href="git-archimport.html">git-archimport(1)</a>
826</dt>
827<dd>
828<p>
Junio C Hamano7c73c662007-01-19 00:37:50829 Import an Arch repository into git.
Junio C Hamano1a4e8412005-12-27 08:17:23830</p>
831</dd>
832<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23833<a href="git-cvsexportcommit.html">git-cvsexportcommit(1)</a>
834</dt>
835<dd>
836<p>
837 Export a single commit to a CVS checkout.
838</p>
839</dd>
840<dt>
Junio C Hamano7c73c662007-01-19 00:37:50841<a href="git-cvsimport.html">git-cvsimport(1)</a>
842</dt>
843<dd>
844<p>
845 Salvage your data out of another SCM people love to hate.
846</p>
847</dd>
848<dt>
Junio C Hamano54559c82006-04-13 07:45:12849<a href="git-cvsserver.html">git-cvsserver(1)</a>
850</dt>
851<dd>
852<p>
853 A CVS server emulator for git.
854</p>
855</dd>
856<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50857<a href="git-imap-send.html">git-imap-send(1)</a>
Junio C Hamano52299462006-12-28 00:59:38858</dt>
859<dd>
860<p>
Junio C Hamano4ad294b2007-01-20 02:22:50861 Dump a mailbox from stdin into an imap folder.
Junio C Hamano1a4e8412005-12-27 08:17:23862</p>
863</dd>
864<dt>
Junio C Hamano33db4372006-06-07 19:51:45865<a href="git-quiltimport.html">git-quiltimport(1)</a>
866</dt>
867<dd>
868<p>
869 Applies a quilt patchset onto the current branch.
870</p>
871</dd>
872<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50873<a href="git-request-pull.html">git-request-pull(1)</a>
Junio C Hamano74640642006-12-27 10:59:55874</dt>
875<dd>
876<p>
Junio C Hamano4ad294b2007-01-20 02:22:50877 Generates a summary of pending changes.
Junio C Hamano74640642006-12-27 10:59:55878</p>
879</dd>
880<dt>
Junio C Hamano4ad294b2007-01-20 02:22:50881<a href="git-send-email.html">git-send-email(1)</a>
Junio C Hamano1a4e8412005-12-27 08:17:23882</dt>
883<dd>
884<p>
Junio C Hamano4ad294b2007-01-20 02:22:50885 Send a collection of patches as emails.
Junio C Hamano7c73c662007-01-19 00:37:50886</p>
887</dd>
888<dt>
Junio C Hamanob518f452006-08-04 00:18:06889<a href="git-svn.html">git-svn(1)</a>
890</dt>
891<dd>
892<p>
893 Bidirectional operation between a single Subversion branch and git.
894</p>
895</dd>
896<dt>
Junio C Hamano1a4e8412005-12-27 08:17:23897<a href="git-svnimport.html">git-svnimport(1)</a>
898</dt>
899<dd>
900<p>
901 Import a SVN repository into git.
902</p>
903</dd>
Junio C Hamano1a4e8412005-12-27 08:17:23904</dl>
905</div>
Junio C Hamanob19b4f02006-10-29 20:47:22906<h2>Low-level commands (plumbing)</h2>
907<div class="sectionbody">
908<p>Although git includes its
909own porcelain layer, its low-level commands are sufficient to support
910development of alternative porcelains. Developers of such porcelains
911might start by reading about <a href="git-update-index.html">git-update-index(1)</a> and
912<a href="git-read-tree.html">git-read-tree(1)</a>.</p>
Junio C Hamano4ad294b2007-01-20 02:22:50913<p>The interface (input, output, set of options and the semantics)
914to these low-level commands are meant to be a lot more stable
915than Porcelain level commands, because these commands are
916primarily for scripted use. The interface to Porcelain commands
917on the other hand are subject to change in order to improve the
918end user experience.</p>
919<p>The following description divides
920the low-level commands into commands that manipulate objects (in
Junio C Hamanob19b4f02006-10-29 20:47:22921the repository, index, and working tree), commands that interrogate and
922compare objects, and commands that move objects and references between
923repositories.</p>
924<h3>Manipulation commands</h3>
925<dl>
926<dt>
927<a href="git-apply.html">git-apply(1)</a>
928</dt>
929<dd>
930<p>
Junio C Hamano7c73c662007-01-19 00:37:50931 Apply a patch on a git index file and a working tree.
Junio C Hamanob19b4f02006-10-29 20:47:22932</p>
933</dd>
934<dt>
935<a href="git-checkout-index.html">git-checkout-index(1)</a>
936</dt>
937<dd>
938<p>
939 Copy files from the index to the working tree.
940</p>
941</dd>
942<dt>
943<a href="git-commit-tree.html">git-commit-tree(1)</a>
944</dt>
945<dd>
946<p>
Junio C Hamano7c73c662007-01-19 00:37:50947 Create a new commit object.
Junio C Hamanob19b4f02006-10-29 20:47:22948</p>
949</dd>
950<dt>
951<a href="git-hash-object.html">git-hash-object(1)</a>
952</dt>
953<dd>
954<p>
Junio C Hamano7c73c662007-01-19 00:37:50955 Compute object ID and optionally creates a blob from a file.
Junio C Hamanob19b4f02006-10-29 20:47:22956</p>
957</dd>
958<dt>
959<a href="git-index-pack.html">git-index-pack(1)</a>
960</dt>
961<dd>
962<p>
Junio C Hamano7c73c662007-01-19 00:37:50963 Build pack index file for an existing packed archive.
Junio C Hamanob19b4f02006-10-29 20:47:22964</p>
965</dd>
966<dt>
Junio C Hamano1de7bc62006-12-17 19:31:54967<a href="git-merge-file.html">git-merge-file(1)</a>
968</dt>
969<dd>
970<p>
Junio C Hamano7c73c662007-01-19 00:37:50971 Run a three-way file merge.
Junio C Hamano1de7bc62006-12-17 19:31:54972</p>
973</dd>
974<dt>
Junio C Hamanob19b4f02006-10-29 20:47:22975<a href="git-merge-index.html">git-merge-index(1)</a>
976</dt>
977<dd>
978<p>
Junio C Hamano7c73c662007-01-19 00:37:50979 Run a merge for files needing merging.
Junio C Hamanob19b4f02006-10-29 20:47:22980</p>
981</dd>
982<dt>
983<a href="git-mktag.html">git-mktag(1)</a>
984</dt>
985<dd>
986<p>
987 Creates a tag object.
988</p>
989</dd>
990<dt>
991<a href="git-mktree.html">git-mktree(1)</a>
992</dt>
993<dd>
994<p>
995 Build a tree-object from ls-tree formatted text.
996</p>
997</dd>
998<dt>
999<a href="git-pack-objects.html">git-pack-objects(1)</a>
1000</dt>
1001<dd>
1002<p>
Junio C Hamano7c73c662007-01-19 00:37:501003 Create a packed archive of objects.
Junio C Hamanob19b4f02006-10-29 20:47:221004</p>
1005</dd>
1006<dt>
1007<a href="git-prune-packed.html">git-prune-packed(1)</a>
1008</dt>
1009<dd>
1010<p>
1011 Remove extra objects that are already in pack files.
1012</p>
1013</dd>
1014<dt>
1015<a href="git-read-tree.html">git-read-tree(1)</a>
1016</dt>
1017<dd>
1018<p>
1019 Reads tree information into the index.
1020</p>
1021</dd>
1022<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501023<a href="git-symbolic-ref.html">git-symbolic-ref(1)</a>
Junio C Hamanob19b4f02006-10-29 20:47:221024</dt>
1025<dd>
1026<p>
Junio C Hamano4ad294b2007-01-20 02:22:501027 Read and modify symbolic refs.
Junio C Hamanob19b4f02006-10-29 20:47:221028</p>
1029</dd>
1030<dt>
1031<a href="git-unpack-objects.html">git-unpack-objects(1)</a>
1032</dt>
1033<dd>
1034<p>
Junio C Hamano7c73c662007-01-19 00:37:501035 Unpack objects from a packed archive.
Junio C Hamanob19b4f02006-10-29 20:47:221036</p>
1037</dd>
1038<dt>
1039<a href="git-update-index.html">git-update-index(1)</a>
1040</dt>
1041<dd>
1042<p>
Junio C Hamano7c73c662007-01-19 00:37:501043 Register file contents in the working tree to the index.
Junio C Hamanob19b4f02006-10-29 20:47:221044</p>
1045</dd>
1046<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501047<a href="git-update-ref.html">git-update-ref(1)</a>
1048</dt>
1049<dd>
1050<p>
1051 Update the object name stored in a ref safely.
1052</p>
1053</dd>
1054<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221055<a href="git-write-tree.html">git-write-tree(1)</a>
1056</dt>
1057<dd>
1058<p>
Junio C Hamano7c73c662007-01-19 00:37:501059 Create a tree object from the current index.
Junio C Hamanob19b4f02006-10-29 20:47:221060</p>
1061</dd>
1062</dl>
1063<h3>Interrogation commands</h3>
1064<dl>
1065<dt>
1066<a href="git-cat-file.html">git-cat-file(1)</a>
1067</dt>
1068<dd>
1069<p>
1070 Provide content or type/size information for repository objects.
1071</p>
1072</dd>
1073<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221074<a href="git-diff-files.html">git-diff-files(1)</a>
1075</dt>
1076<dd>
1077<p>
1078 Compares files in the working tree and the index.
1079</p>
1080</dd>
1081<dt>
Junio C Hamano7c73c662007-01-19 00:37:501082<a href="git-diff-index.html">git-diff-index(1)</a>
1083</dt>
1084<dd>
1085<p>
1086 Compares content and mode of blobs between the index and repository.
1087</p>
1088</dd>
1089<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221090<a href="git-diff-stages.html">git-diff-stages(1)</a>
1091</dt>
1092<dd>
1093<p>
Junio C Hamano7c73c662007-01-19 00:37:501094 Compares two merge stages in the index.
Junio C Hamanob19b4f02006-10-29 20:47:221095</p>
1096</dd>
1097<dt>
1098<a href="git-diff-tree.html">git-diff-tree(1)</a>
1099</dt>
1100<dd>
1101<p>
1102 Compares the content and mode of blobs found via two tree objects.
1103</p>
1104</dd>
1105<dt>
1106<a href="git-for-each-ref.html">git-for-each-ref(1)</a>
1107</dt>
1108<dd>
1109<p>
1110 Output information on each ref.
1111</p>
1112</dd>
1113<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221114<a href="git-ls-files.html">git-ls-files(1)</a>
1115</dt>
1116<dd>
1117<p>
Junio C Hamano7c73c662007-01-19 00:37:501118 Show information about files in the index and the working tree.
Junio C Hamanob19b4f02006-10-29 20:47:221119</p>
1120</dd>
1121<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501122<a href="git-ls-remote.html">git-ls-remote(1)</a>
1123</dt>
1124<dd>
1125<p>
1126 List references in a remote repository.
1127</p>
1128</dd>
1129<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221130<a href="git-ls-tree.html">git-ls-tree(1)</a>
1131</dt>
1132<dd>
1133<p>
Junio C Hamano7c73c662007-01-19 00:37:501134 List the contents of a tree object.
Junio C Hamanob19b4f02006-10-29 20:47:221135</p>
1136</dd>
1137<dt>
1138<a href="git-merge-base.html">git-merge-base(1)</a>
1139</dt>
1140<dd>
1141<p>
Junio C Hamano7c73c662007-01-19 00:37:501142 Find as good common ancestors as possible for a merge.
Junio C Hamanob19b4f02006-10-29 20:47:221143</p>
1144</dd>
1145<dt>
1146<a href="git-name-rev.html">git-name-rev(1)</a>
1147</dt>
1148<dd>
1149<p>
1150 Find symbolic names for given revs.
1151</p>
1152</dd>
1153<dt>
1154<a href="git-pack-redundant.html">git-pack-redundant(1)</a>
1155</dt>
1156<dd>
1157<p>
1158 Find redundant pack files.
1159</p>
1160</dd>
1161<dt>
1162<a href="git-rev-list.html">git-rev-list(1)</a>
1163</dt>
1164<dd>
1165<p>
1166 Lists commit objects in reverse chronological order.
1167</p>
1168</dd>
1169<dt>
1170<a href="git-show-index.html">git-show-index(1)</a>
1171</dt>
1172<dd>
1173<p>
Junio C Hamano7c73c662007-01-19 00:37:501174 Show packed archive index.
Junio C Hamanob19b4f02006-10-29 20:47:221175</p>
1176</dd>
1177<dt>
Junio C Hamanod8c9d432006-11-07 07:19:131178<a href="git-show-ref.html">git-show-ref(1)</a>
1179</dt>
1180<dd>
1181<p>
1182 List references in a local repository.
1183</p>
1184</dd>
1185<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221186<a href="git-tar-tree.html">git-tar-tree(1)</a>
1187</dt>
1188<dd>
1189<p>
Junio C Hamano7c73c662007-01-19 00:37:501190 Create a tar archive of the files in the named tree object.
Junio C Hamanob19b4f02006-10-29 20:47:221191</p>
1192</dd>
1193<dt>
1194<a href="git-unpack-file.html">git-unpack-file(1)</a>
1195</dt>
1196<dd>
1197<p>
1198 Creates a temporary file with a blob's contents.
1199</p>
1200</dd>
1201<dt>
1202<a href="git-var.html">git-var(1)</a>
1203</dt>
1204<dd>
1205<p>
Junio C Hamano7c73c662007-01-19 00:37:501206 Show a git logical variable.
Junio C Hamanob19b4f02006-10-29 20:47:221207</p>
1208</dd>
1209<dt>
1210<a href="git-verify-pack.html">git-verify-pack(1)</a>
1211</dt>
1212<dd>
1213<p>
Junio C Hamano7c73c662007-01-19 00:37:501214 Validate packed git archive files.
Junio C Hamanob19b4f02006-10-29 20:47:221215</p>
1216</dd>
1217</dl>
1218<p>In general, the interrogate commands do not touch the files in
1219the working tree.</p>
1220<h3>Synching repositories</h3>
1221<dl>
1222<dt>
Junio C Hamano4ad294b2007-01-20 02:22:501223<a href="git-daemon.html">git-daemon(1)</a>
1224</dt>
1225<dd>
1226<p>
1227 A really simple server for git repositories.
1228</p>
1229</dd>
1230<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221231<a href="git-fetch-pack.html">git-fetch-pack(1)</a>
1232</dt>
1233<dd>
1234<p>
Junio C Hamano7c73c662007-01-19 00:37:501235 Receive missing objects from another repository.
Junio C Hamanob19b4f02006-10-29 20:47:221236</p>
1237</dd>
1238<dt>
Junio C Hamano7c73c662007-01-19 00:37:501239<a href="git-local-fetch.html">git-local-fetch(1)</a>
1240</dt>
1241<dd>
1242<p>
1243 Duplicate another git repository on a local system.
1244</p>
1245</dd>
1246<dt>
Junio C Hamano7c73c662007-01-19 00:37:501247<a href="git-send-pack.html">git-send-pack(1)</a>
1248</dt>
1249<dd>
1250<p>
1251 Push objects over git protocol to another reposiotory.
Junio C Hamanob19b4f02006-10-29 20:47:221252</p>
1253</dd>
1254<dt>
Junio C Hamanob19b4f02006-10-29 20:47:221255<a href="git-ssh-fetch.html">git-ssh-fetch(1)</a>
1256</dt>
1257<dd>
1258<p>
Junio C Hamano7c73c662007-01-19 00:37:501259 Fetch from a remote repository over ssh connection.
Junio C Hamanob19b4f02006-10-29 20:47:221260</p>
1261</dd>
1262<dt>
1263<a href="git-ssh-upload.html">git-ssh-upload(1)</a>
1264</dt>
1265<dd>
1266<p>
Junio C Hamano7c73c662007-01-19 00:37:501267 Push to a remote repository over ssh connection.
Junio C Hamanob19b4f02006-10-29 20:47:221268</p>
1269</dd>
1270<dt>
1271<a href="git-update-server-info.html">git-update-server-info(1)</a>
1272</dt>
1273<dd>
1274<p>
Junio C Hamano7c73c662007-01-19 00:37:501275 Update auxiliary info file to help dumb servers.
Junio C Hamanob19b4f02006-10-29 20:47:221276</p>
1277</dd>
Junio C Hamano4ad294b2007-01-20 02:22:501278</dl>
1279<p>The following are helper programs used by the above; end users
1280typically do not use them directly.</p>
1281<dl>
1282<dt>
1283<a href="git-http-fetch.html">git-http-fetch(1)</a>
1284</dt>
1285<dd>
1286<p>
1287 Download from a remote git repository via HTTP.
1288</p>
1289</dd>
1290<dt>
1291<a href="git-http-push.html">git-http-push(1)</a>
1292</dt>
1293<dd>
1294<p>
1295 Push objects over HTTP/DAV to another repository.
1296</p>
1297</dd>
1298<dt>
1299<a href="git-parse-remote.html">git-parse-remote(1)</a>
1300</dt>
1301<dd>
1302<p>
1303 Routines to help parsing remote repository access parameters.
1304</p>
1305</dd>
1306<dt>
1307<a href="git-receive-pack.html">git-receive-pack(1)</a>
1308</dt>
1309<dd>
1310<p>
1311 Receive what is pushed into the repository.
1312</p>
1313</dd>
1314<dt>
1315<a href="git-shell.html">git-shell(1)</a>
1316</dt>
1317<dd>
1318<p>
1319 Restricted login shell for GIT-only SSH access.
1320</p>
1321</dd>
Junio C Hamanob19b4f02006-10-29 20:47:221322<dt>
1323<a href="git-upload-archive.html">git-upload-archive(1)</a>
1324</dt>
1325<dd>
1326<p>
Junio C Hamano7c73c662007-01-19 00:37:501327 Send archive back to git-archive.
Junio C Hamanob19b4f02006-10-29 20:47:221328</p>
1329</dd>
1330<dt>
1331<a href="git-upload-pack.html">git-upload-pack(1)</a>
1332</dt>
1333<dd>
1334<p>
Junio C Hamano7c73c662007-01-19 00:37:501335 Send objects packed back to git-fetch-pack.
Junio C Hamanob19b4f02006-10-29 20:47:221336</p>
1337</dd>
1338</dl>
Junio C Hamano4ad294b2007-01-20 02:22:501339<h3>Internal helper commands</h3>
1340<p>These are internal helper commands used by other commands; end
1341users typically do not use them directly.</p>
1342<dl>
1343<dt>
1344<a href="git-applypatch.html">git-applypatch(1)</a>
1345</dt>
1346<dd>
1347<p>
1348 Apply one patch extracted from an e-mail.
1349</p>
1350</dd>
1351<dt>
1352<a href="git-check-ref-format.html">git-check-ref-format(1)</a>
1353</dt>
1354<dd>
1355<p>
1356 Make sure ref name is well formed.
1357</p>
1358</dd>
1359<dt>
1360<a href="git-fmt-merge-msg.html">git-fmt-merge-msg(1)</a>
1361</dt>
1362<dd>
1363<p>
1364 Produce a merge commit message.
1365</p>
1366</dd>
1367<dt>
1368<a href="git-mailinfo.html">git-mailinfo(1)</a>
1369</dt>
1370<dd>
1371<p>
1372 Extracts patch and authorship from a single e-mail message.
1373</p>
1374</dd>
1375<dt>
1376<a href="git-mailsplit.html">git-mailsplit(1)</a>
1377</dt>
1378<dd>
1379<p>
1380 Simple UNIX mbox splitter program.
1381</p>
1382</dd>
1383<dt>
1384<a href="git-merge-one-file.html">git-merge-one-file(1)</a>
1385</dt>
1386<dd>
1387<p>
1388 The standard helper program to use with git-merge-index.
1389</p>
1390</dd>
1391<dt>
1392<a href="git-patch-id.html">git-patch-id(1)</a>
1393</dt>
1394<dd>
1395<p>
1396 Compute unique ID for a patch.
1397</p>
1398</dd>
1399<dt>
1400<a href="git-peek-remote.html">git-peek-remote(1)</a>
1401</dt>
1402<dd>
1403<p>
1404 List the references in a remote repository.
1405</p>
1406</dd>
1407<dt>
1408<a href="git-sh-setup.html">git-sh-setup(1)</a>
1409</dt>
1410<dd>
1411<p>
1412 Common git shell script setup code.
1413</p>
1414</dd>
1415<dt>
1416<a href="git-stripspace.html">git-stripspace(1)</a>
1417</dt>
1418<dd>
1419<p>
1420 Filter out empty lines.
1421</p>
1422</dd>
1423</dl>
Junio C Hamanob19b4f02006-10-29 20:47:221424</div>
Junio C Hamano1a4e8412005-12-27 08:17:231425<h2>Configuration Mechanism</h2>
1426<div class="sectionbody">
1427<p>Starting from 0.99.9 (actually mid 0.99.8.GIT), <tt>.git/config</tt> file
1428is used to hold per-repository configuration options. It is a
Junio C Hamano51c2ab02006-07-09 20:38:541429simple text file modeled after <tt>.ini</tt> format familiar to some
Junio C Hamano1a4e8412005-12-27 08:17:231430people. Here is an example:</p>
1431<div class="listingblock">
1432<div class="content">
1433<pre><tt>#
1434# A '#' or ';' character indicates a comment.
1435#
1436
1437; core variables
1438[core]
1439 ; Don't trust file modes
1440 filemode = false
1441
1442; user identity
1443[user]
1444 name = "Junio C Hamano"
1445 email = "junkio@twinsun.com"
1446</tt></pre>
1447</div></div>
1448<p>Various commands read from the configuration file and adjust
1449their operation accordingly.</p>
1450</div>
1451<h2>Identifier Terminology</h2>
1452<div class="sectionbody">
1453<dl>
1454<dt>
1455&lt;object&gt;
1456</dt>
1457<dd>
1458<p>
1459 Indicates the object name for any type of object.
1460</p>
1461</dd>
1462<dt>
1463&lt;blob&gt;
1464</dt>
1465<dd>
1466<p>
1467 Indicates a blob object name.
1468</p>
1469</dd>
1470<dt>
1471&lt;tree&gt;
1472</dt>
1473<dd>
1474<p>
1475 Indicates a tree object name.
1476</p>
1477</dd>
1478<dt>
1479&lt;commit&gt;
1480</dt>
1481<dd>
1482<p>
1483 Indicates a commit object name.
1484</p>
1485</dd>
1486<dt>
1487&lt;tree-ish&gt;
1488</dt>
1489<dd>
1490<p>
1491 Indicates a tree, commit or tag object name. A
1492 command that takes a &lt;tree-ish&gt; argument ultimately wants to
1493 operate on a &lt;tree&gt; object but automatically dereferences
1494 &lt;commit&gt; and &lt;tag&gt; objects that point at a &lt;tree&gt;.
1495</p>
1496</dd>
1497<dt>
1498&lt;type&gt;
1499</dt>
1500<dd>
1501<p>
1502 Indicates that an object type is required.
1503 Currently one of: <tt>blob</tt>, <tt>tree</tt>, <tt>commit</tt>, or <tt>tag</tt>.
1504</p>
1505</dd>
1506<dt>
1507&lt;file&gt;
1508</dt>
1509<dd>
1510<p>
1511 Indicates a filename - almost always relative to the
1512 root of the tree structure <tt>GIT_INDEX_FILE</tt> describes.
1513</p>
1514</dd>
1515</dl>
1516</div>
1517<h2>Symbolic Identifiers</h2>
1518<div class="sectionbody">
1519<p>Any git command accepting any &lt;object&gt; can also use the following
1520symbolic notation:</p>
1521<dl>
1522<dt>
1523HEAD
1524</dt>
1525<dd>
1526<p>
1527 indicates the head of the current branch (i.e. the
1528 contents of <tt>$GIT_DIR/HEAD</tt>).
1529</p>
1530</dd>
1531<dt>
1532&lt;tag&gt;
1533</dt>
1534<dd>
1535<p>
1536 a valid tag <em>name</em>
1537 (i.e. the contents of <tt>$GIT_DIR/refs/tags/&lt;tag&gt;</tt>).
1538</p>
1539</dd>
1540<dt>
1541&lt;head&gt;
1542</dt>
1543<dd>
1544<p>
1545 a valid head <em>name</em>
1546 (i.e. the contents of <tt>$GIT_DIR/refs/heads/&lt;head&gt;</tt>).
1547</p>
1548</dd>
Junio C Hamano1a4e8412005-12-27 08:17:231549</dl>
Junio C Hamanoff4b4312006-10-25 22:55:311550<p>For a more complete list of ways to spell object names, see
1551"SPECIFYING REVISIONS" section in <a href="git-rev-parse.html">git-rev-parse(1)</a>.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231552</div>
1553<h2>File/Directory Structure</h2>
1554<div class="sectionbody">
1555<p>Please see <a href="repository-layout.html">repository layout</a> document.</p>
Junio C Hamano818f7d62006-03-26 01:49:301556<p>Read <a href="hooks.html">hooks</a> for more details about each hook.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231557<p>Higher level SCMs may provide and manage additional information in the
1558<tt>$GIT_DIR</tt>.</p>
1559</div>
1560<h2>Terminology</h2>
1561<div class="sectionbody">
1562<p>Please see <a href="glossary.html">glossary</a> document.</p>
1563</div>
1564<h2>Environment Variables</h2>
1565<div class="sectionbody">
1566<p>Various git commands use the following environment variables:</p>
1567<h3>The git Repository</h3>
1568<p>These environment variables apply to <em>all</em> core git commands. Nb: it
1569is worth noting that they may be used/overridden by SCMS sitting above
1570git so take care if using Cogito etc.</p>
1571<dl>
1572<dt>
1573<em>GIT_INDEX_FILE</em>
1574</dt>
1575<dd>
1576<p>
1577 This environment allows the specification of an alternate
1578 index file. If not specified, the default of <tt>$GIT_DIR/index</tt>
1579 is used.
1580</p>
1581</dd>
1582<dt>
1583<em>GIT_OBJECT_DIRECTORY</em>
1584</dt>
1585<dd>
1586<p>
1587 If the object storage directory is specified via this
1588 environment variable then the sha1 directories are created
1589 underneath - otherwise the default <tt>$GIT_DIR/objects</tt>
1590 directory is used.
1591</p>
1592</dd>
1593<dt>
1594<em>GIT_ALTERNATE_OBJECT_DIRECTORIES</em>
1595</dt>
1596<dd>
1597<p>
1598 Due to the immutable nature of git objects, old objects can be
1599 archived into shared, read-only directories. This variable
1600 specifies a ":" separated list of git object directories which
1601 can be used to search for git objects. New objects will not be
1602 written to these directories.
1603</p>
1604</dd>
1605<dt>
1606<em>GIT_DIR</em>
1607</dt>
1608<dd>
1609<p>
1610 If the <em>GIT_DIR</em> environment variable is set then it
1611 specifies a path to use instead of the default <tt>.git</tt>
1612 for the base of the repository.
1613</p>
1614</dd>
1615</dl>
1616<h3>git Commits</h3>
1617<dl>
1618<dt>
1619<em>GIT_AUTHOR_NAME</em>
1620</dt>
1621<dt>
1622<em>GIT_AUTHOR_EMAIL</em>
1623</dt>
1624<dt>
1625<em>GIT_AUTHOR_DATE</em>
1626</dt>
1627<dt>
1628<em>GIT_COMMITTER_NAME</em>
1629</dt>
1630<dt>
1631<em>GIT_COMMITTER_EMAIL</em>
1632</dt>
1633<dd>
1634<p>
1635 see <a href="git-commit-tree.html">git-commit-tree(1)</a>
1636</p>
1637</dd>
1638</dl>
1639<h3>git Diffs</h3>
1640<dl>
1641<dt>
1642<em>GIT_DIFF_OPTS</em>
1643</dt>
Junio C Hamano1c437122006-11-28 02:22:251644<dd>
1645<p>
1646 Only valid setting is "--unified=??" or "-u??" to set the
1647 number of context lines shown when a unified diff is created.
1648 This takes precedence over any "-U" or "--unified" option
1649 value passed on the git diff command line.
1650</p>
1651</dd>
Junio C Hamano1a4e8412005-12-27 08:17:231652<dt>
1653<em>GIT_EXTERNAL_DIFF</em>
1654</dt>
1655<dd>
1656<p>
Junio C Hamano1c437122006-11-28 02:22:251657 When the environment variable <em>GIT_EXTERNAL_DIFF</em> is set, the
1658 program named by it is called, instead of the diff invocation
1659 described above. For a path that is added, removed, or modified,
1660 <em>GIT_EXTERNAL_DIFF</em> is called with 7 parameters:
Junio C Hamano1a4e8412005-12-27 08:17:231661</p>
Junio C Hamano1c437122006-11-28 02:22:251662<div class="literalblock">
1663<div class="content">
1664<pre><tt>path old-file old-hex old-mode new-file new-hex new-mode</tt></pre>
1665</div></div>
1666<p>where:</p>
1667<div class="hlist"><table>
1668<tr>
1669<td class="hlist1">
1670&lt;old|new&gt;-file
1671</td>
1672<td class="hlist2">
1673are files GIT_EXTERNAL_DIFF can use to read the
1674 contents of &lt;old|new&gt;,
1675</td>
1676</tr>
1677<tr>
1678<td class="hlist1">
1679&lt;old|new&gt;-hex
1680</td>
1681<td class="hlist2">
1682are the 40-hexdigit SHA1 hashes,
1683</td>
1684</tr>
1685<tr>
1686<td class="hlist1">
1687&lt;old|new&gt;-mode
1688</td>
1689<td class="hlist2">
1690are the octal representation of the file modes.
1691</td>
1692</tr>
1693</table></div>
1694<p>The file parameters can point at the user's working file
1695(e.g. <tt>new-file</tt> in "git-diff-files"), <tt>/dev/null</tt> (e.g. <tt>old-file</tt>
1696when a new file is added), or a temporary file (e.g. <tt>old-file</tt> in the
1697index). <em>GIT_EXTERNAL_DIFF</em> should not worry about unlinking the
1698temporary file --- it is removed when <em>GIT_EXTERNAL_DIFF</em> exits.</p>
1699<p>For a path that is unmerged, <em>GIT_EXTERNAL_DIFF</em> is called with 1
1700parameter, &lt;path&gt;.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231701</dd>
1702</dl>
Junio C Hamano7ccb9fd2006-07-15 01:38:401703<h3>other</h3>
1704<dl>
1705<dt>
Junio C Hamano85e45fa2006-08-13 07:47:411706<em>GIT_PAGER</em>
1707</dt>
1708<dd>
1709<p>
1710 This environment variable overrides <tt>$PAGER</tt>.
1711</p>
1712</dd>
1713<dt>
Junio C Hamano7ccb9fd2006-07-15 01:38:401714<em>GIT_TRACE</em>
1715</dt>
1716<dd>
1717<p>
Junio C Hamanoef4b48b2006-09-04 10:08:341718 If this variable is set to "1", "2" or "true" (comparison
1719 is case insensitive), git will print <tt>trace:</tt> messages on
Junio C Hamano7ccb9fd2006-07-15 01:38:401720 stderr telling about alias expansion, built-in command
1721 execution and external command execution.
Junio C Hamanoef4b48b2006-09-04 10:08:341722 If this variable is set to an integer value greater than 1
1723 and lower than 10 (strictly) then git will interpret this
1724 value as an open file descriptor and will try to write the
1725 trace messages into this file descriptor.
1726 Alternatively, if this variable is set to an absolute path
1727 (starting with a <em>/</em> character), git will interpret this
1728 as a file path and will try to write the trace messages
1729 into it.
Junio C Hamano7ccb9fd2006-07-15 01:38:401730</p>
1731</dd>
1732</dl>
Junio C Hamano1a4e8412005-12-27 08:17:231733</div>
1734<h2>Discussion<a id="Discussion"></a></h2>
1735<div class="sectionbody">
1736<p>"git" can mean anything, depending on your mood.</p>
1737<ul>
1738<li>
1739<p>
1740random three-letter combination that is pronounceable, and not
1741 actually used by any common UNIX command. The fact that it is a
1742 mispronunciation of "get" may or may not be relevant.
1743</p>
1744</li>
1745<li>
1746<p>
1747stupid. contemptible and despicable. simple. Take your pick from the
1748 dictionary of slang.
1749</p>
1750</li>
1751<li>
1752<p>
1753"global information tracker": you're in a good mood, and it actually
1754 works for you. Angels sing, and a light suddenly fills the room.
1755</p>
1756</li>
1757<li>
1758<p>
1759"goddamn idiotic truckload of sh*t": when it breaks
1760</p>
1761</li>
1762</ul>
Junio C Hamano4f9a6052007-01-17 20:25:161763<p>This is a (not so) stupid but extremely fast directory content manager.
1764It doesn't do a whole lot at its core, but what it <em>does</em> do is track
1765directory contents efficiently.</p>
Junio C Hamano1a4e8412005-12-27 08:17:231766<p>There are two object abstractions: the "object database", and the
1767"current directory cache" aka "index".</p>
1768<h3>The Object Database</h3>
1769<p>The object database is literally just a content-addressable collection
1770of objects. All objects are named by their content, which is
1771approximated by the SHA1 hash of the object itself. Objects may refer
1772to other objects (by referencing their SHA1 hash), and so you can
1773build up a hierarchy of objects.</p>
1774<p>All objects have a statically determined "type" aka "tag", which is
1775determined at object creation time, and which identifies the format of
1776the object (i.e. how it is used, and how it can refer to other
1777objects). There are currently four different object types: "blob",
1778"tree", "commit" and "tag".</p>
1779<p>A "blob" object cannot refer to any other object, and is, like the type
1780implies, a pure storage object containing some user data. It is used to
1781actually store the file data, i.e. a blob object is associated with some
1782particular version of some file.</p>
1783<p>A "tree" object is an object that ties one or more "blob" objects into a
1784directory structure. In addition, a tree object can refer to other tree
1785objects, thus creating a directory hierarchy.</p>
1786<p>A "commit" object ties such directory hierarchies together into
1787a DAG of revisions - each "commit" is associated with exactly one tree
1788(the directory hierarchy at the time of the commit). In addition, a
1789"commit" refers to one or more "parent" commit objects that describe the
1790history of how we arrived at that directory hierarchy.</p>
1791<p>As a special case, a commit object with no parents is called the "root"
1792object, and is the point of an initial project commit. Each project
1793must have at least one root, and while you can tie several different
1794root objects together into one project by creating a commit object which
1795has two or more separate roots as its ultimate parents, that's probably
1796just going to confuse people. So aim for the notion of "one root object
1797per project", even if git itself does not enforce that.</p>
1798<p>A "tag" object symbolically identifies and can be used to sign other
1799objects. It contains the identifier and type of another object, a
1800symbolic name (of course!) and, optionally, a signature.</p>
1801<p>Regardless of object type, all objects share the following
1802characteristics: they are all deflated with zlib, and have a header
1803that not only specifies their type, but also provides size information
1804about the data in the object. It's worth noting that the SHA1 hash
1805that is used to name the object is the hash of the original data
1806plus this header, so <tt>sha1sum</tt> <em>file</em> does not match the object name
1807for <em>file</em>.
1808(Historical note: in the dawn of the age of git the hash
1809was the sha1 of the <em>compressed</em> object.)</p>
1810<p>As a result, the general consistency of an object can always be tested
1811independently of the contents or the type of the object: all objects can
1812be validated by verifying that (a) their hashes match the content of the
1813file and (b) the object successfully inflates to a stream of bytes that
1814forms a sequence of &lt;ascii type without space&gt; + &lt;space&gt; + &lt;ascii decimal
1815size&gt; + &lt;byte\0&gt; + &lt;binary object data&gt;.</p>
1816<p>The structured objects can further have their structure and
1817connectivity to other objects verified. This is generally done with
1818the <tt>git-fsck-objects</tt> program, which generates a full dependency graph
1819of all objects, and verifies their internal consistency (in addition
1820to just verifying their superficial consistency through the hash).</p>
1821<p>The object types in some more detail:</p>
1822<h3>Blob Object</h3>
1823<p>A "blob" object is nothing but a binary blob of data, and doesn't
1824refer to anything else. There is no signature or any other
1825verification of the data, so while the object is consistent (it <em>is</em>
1826indexed by its sha1 hash, so the data itself is certainly correct), it
1827has absolutely no other attributes. No name associations, no
1828permissions. It is purely a blob of data (i.e. normally "file
1829contents").</p>
1830<p>In particular, since the blob is entirely defined by its data, if two
1831files in a directory tree (or in multiple different versions of the
1832repository) have the same contents, they will share the same blob
1833object. The object is totally independent of its location in the
1834directory tree, and renaming a file does not change the object that
1835file is associated with in any way.</p>
1836<p>A blob is typically created when <a href="git-update-index.html">git-update-index(1)</a>
1837is run, and its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>.</p>
1838<h3>Tree Object</h3>
1839<p>The next hierarchical object type is the "tree" object. A tree object
1840is a list of mode/name/blob data, sorted by name. Alternatively, the
1841mode data may specify a directory mode, in which case instead of
1842naming a blob, that name is associated with another TREE object.</p>
1843<p>Like the "blob" object, a tree object is uniquely determined by the
1844set contents, and so two separate but identical trees will always
1845share the exact same object. This is true at all levels, i.e. it's
1846true for a "leaf" tree (which does not refer to any other trees, only
1847blobs) as well as for a whole subdirectory.</p>
1848<p>For that reason a "tree" object is just a pure data abstraction: it
1849has no history, no signatures, no verification of validity, except
1850that since the contents are again protected by the hash itself, we can
1851trust that the tree is immutable and its contents never change.</p>
1852<p>So you can trust the contents of a tree to be valid, the same way you
1853can trust the contents of a blob, but you don't know where those
1854contents <em>came</em> from.</p>
1855<p>Side note on trees: since a "tree" object is a sorted list of
1856"filename+content", you can create a diff between two trees without
1857actually having to unpack two trees. Just ignore all common parts,
1858and your diff will look right. In other words, you can effectively
1859(and efficiently) tell the difference between any two random trees by
1860O(n) where "n" is the size of the difference, rather than the size of
1861the tree.</p>
1862<p>Side note 2 on trees: since the name of a "blob" depends entirely and
1863exclusively on its contents (i.e. there are no names or permissions
1864involved), you can see trivial renames or permission changes by
1865noticing that the blob stayed the same. However, renames with data
1866changes need a smarter "diff" implementation.</p>
1867<p>A tree is created with <a href="git-write-tree.html">git-write-tree(1)</a> and
1868its data can be accessed by <a href="git-ls-tree.html">git-ls-tree(1)</a>.
1869Two trees can be compared with <a href="git-diff-tree.html">git-diff-tree(1)</a>.</p>
1870<h3>Commit Object</h3>
1871<p>The "commit" object is an object that introduces the notion of
1872history into the picture. In contrast to the other objects, it
1873doesn't just describe the physical state of a tree, it describes how
1874we got there, and why.</p>
1875<p>A "commit" is defined by the tree-object that it results in, the
1876parent commits (zero, one or more) that led up to that point, and a
1877comment on what happened. Again, a commit is not trusted per se:
1878the contents are well-defined and "safe" due to the cryptographically
1879strong signatures at all levels, but there is no reason to believe
1880that the tree is "good" or that the merge information makes sense.
1881The parents do not have to actually have any relationship with the
1882result, for example.</p>
1883<p>Note on commits: unlike real SCM's, commits do not contain
1884rename information or file mode change information. All of that is
1885implicit in the trees involved (the result tree, and the result trees
1886of the parents), and describing that makes no sense in this idiotic
1887file manager.</p>
1888<p>A commit is created with <a href="git-commit-tree.html">git-commit-tree(1)</a> and
1889its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>.</p>
1890<h3>Trust</h3>
1891<p>An aside on the notion of "trust". Trust is really outside the scope
1892of "git", but it's worth noting a few things. First off, since
1893everything is hashed with SHA1, you <em>can</em> trust that an object is
1894intact and has not been messed with by external sources. So the name
1895of an object uniquely identifies a known state - just not a state that
1896you may want to trust.</p>
1897<p>Furthermore, since the SHA1 signature of a commit refers to the
1898SHA1 signatures of the tree it is associated with and the signatures
1899of the parent, a single named commit specifies uniquely a whole set
1900of history, with full contents. You can't later fake any step of the
1901way once you have the name of a commit.</p>
1902<p>So to introduce some real trust in the system, the only thing you need
1903to do is to digitally sign just <em>one</em> special note, which includes the
1904name of a top-level commit. Your digital signature shows others
1905that you trust that commit, and the immutability of the history of
1906commits tells others that they can trust the whole history.</p>
1907<p>In other words, you can easily validate a whole archive by just
1908sending out a single email that tells the people the name (SHA1 hash)
1909of the top commit, and digitally sign that email using something
1910like GPG/PGP.</p>
1911<p>To assist in this, git also provides the tag object&#8230;</p>
1912<h3>Tag Object</h3>
1913<p>Git provides the "tag" object to simplify creating, managing and
1914exchanging symbolic and signed tokens. The "tag" object at its
1915simplest simply symbolically identifies another object by containing
1916the sha1, type and symbolic name.</p>
1917<p>However it can optionally contain additional signature information
1918(which git doesn't care about as long as there's less than 8k of
1919it). This can then be verified externally to git.</p>
1920<p>Note that despite the tag features, "git" itself only handles content
1921integrity; the trust framework (and signature provision and
1922verification) has to come from outside.</p>
1923<p>A tag is created with <a href="git-mktag.html">git-mktag(1)</a>,
1924its data can be accessed by <a href="git-cat-file.html">git-cat-file(1)</a>,
1925and the signature can be verified by
1926<a href="git-verify-tag.html">git-verify-tag(1)</a>.</p>
1927</div>
1928<h2>The "index" aka "Current Directory Cache"</h2>
1929<div class="sectionbody">
1930<p>The index is a simple binary file, which contains an efficient
1931representation of a virtual directory content at some random time. It
1932does so by a simple array that associates a set of names, dates,
1933permissions and content (aka "blob") objects together. The cache is
1934always kept ordered by name, and names are unique (with a few very
1935specific rules) at any point in time, but the cache has no long-term
1936meaning, and can be partially updated at any time.</p>
1937<p>In particular, the index certainly does not need to be consistent with
1938the current directory contents (in fact, most operations will depend on
1939different ways to make the index <em>not</em> be consistent with the directory
1940hierarchy), but it has three very important attributes:</p>
1941<p><em>(a) it can re-generate the full state it caches (not just the
1942directory structure: it contains pointers to the "blob" objects so
1943that it can regenerate the data too)</em></p>
1944<p>As a special case, there is a clear and unambiguous one-way mapping
1945from a current directory cache to a "tree object", which can be
1946efficiently created from just the current directory cache without
1947actually looking at any other data. So a directory cache at any one
1948time uniquely specifies one and only one "tree" object (but has
1949additional data to make it easy to match up that tree object with what
1950has happened in the directory)</p>
1951<p><em>(b) it has efficient methods for finding inconsistencies between that
1952cached state ("tree object waiting to be instantiated") and the
1953current state.</em></p>
1954<p><em>(c) it can additionally efficiently represent information about merge
1955conflicts between different tree objects, allowing each pathname to be
1956associated with sufficient information about the trees involved that
1957you can create a three-way merge between them.</em></p>
1958<p>Those are the three ONLY things that the directory cache does. It's a
1959cache, and the normal operation is to re-generate it completely from a
1960known tree object, or update/compare it with a live tree that is being
1961developed. If you blow the directory cache away entirely, you generally
1962haven't lost any information as long as you have the name of the tree
1963that it described.</p>
1964<p>At the same time, the index is at the same time also the
1965staging area for creating new trees, and creating a new tree always
1966involves a controlled modification of the index file. In particular,
1967the index file can have the representation of an intermediate tree that
1968has not yet been instantiated. So the index can be thought of as a
1969write-back cache, which can contain dirty information that has not yet
1970been written back to the backing store.</p>
1971</div>
1972<h2>The Workflow</h2>
1973<div class="sectionbody">
1974<p>Generally, all "git" operations work on the index file. Some operations
1975work <strong>purely</strong> on the index file (showing the current state of the
1976index), but most operations move data to and from the index file. Either
1977from the database or from the working directory. Thus there are four
1978main combinations:</p>
1979<h3>1) working directory -&gt; index</h3>
1980<p>You update the index with information from the working directory with
1981the <a href="git-update-index.html">git-update-index(1)</a> command. You
1982generally update the index information by just specifying the filename
1983you want to update, like so:</p>
1984<div class="literalblock">
1985<div class="content">
1986<pre><tt>git-update-index filename</tt></pre>
1987</div></div>
1988<p>but to avoid common mistakes with filename globbing etc, the command
1989will not normally add totally new entries or remove old entries,
1990i.e. it will normally just update existing cache entries.</p>
1991<p>To tell git that yes, you really do realize that certain files no
1992longer exist, or that new files should be added, you
1993should use the <tt>--remove</tt> and <tt>--add</tt> flags respectively.</p>
1994<p>NOTE! A <tt>--remove</tt> flag does <em>not</em> mean that subsequent filenames will
1995necessarily be removed: if the files still exist in your directory
1996structure, the index will be updated with their new status, not
1997removed. The only thing <tt>--remove</tt> means is that update-cache will be
1998considering a removed file to be a valid thing, and if the file really
1999does not exist any more, it will update the index accordingly.</p>
2000<p>As a special case, you can also do <tt>git-update-index --refresh</tt>, which
2001will refresh the "stat" information of each index to match the current
2002stat information. It will <em>not</em> update the object status itself, and
2003it will only update the fields that are used to quickly test whether
2004an object still matches its old backing store object.</p>
2005<h3>2) index -&gt; object database</h3>
2006<p>You write your current index file to a "tree" object with the program</p>
2007<div class="literalblock">
2008<div class="content">
2009<pre><tt>git-write-tree</tt></pre>
2010</div></div>
2011<p>that doesn't come with any options - it will just write out the
2012current index into the set of tree objects that describe that state,
2013and it will return the name of the resulting top-level tree. You can
2014use that tree to re-generate the index at any time by going in the
2015other direction:</p>
2016<h3>3) object database -&gt; index</h3>
2017<p>You read a "tree" file from the object database, and use that to
2018populate (and overwrite - don't do this if your index contains any
2019unsaved state that you might want to restore later!) your current
2020index. Normal operation is just</p>
2021<div class="literalblock">
2022<div class="content">
2023<pre><tt>git-read-tree &lt;sha1 of tree&gt;</tt></pre>
2024</div></div>
2025<p>and your index file will now be equivalent to the tree that you saved
2026earlier. However, that is only your <em>index</em> file: your working
2027directory contents have not been modified.</p>
2028<h3>4) index -&gt; working directory</h3>
2029<p>You update your working directory from the index by "checking out"
2030files. This is not a very common operation, since normally you'd just
2031keep your files updated, and rather than write to your working
2032directory, you'd tell the index files about the changes in your
2033working directory (i.e. <tt>git-update-index</tt>).</p>
2034<p>However, if you decide to jump to a new version, or check out somebody
2035else's version, or just restore a previous tree, you'd populate your
2036index file with read-tree, and then you need to check out the result
2037with</p>
2038<div class="literalblock">
2039<div class="content">
2040<pre><tt>git-checkout-index filename</tt></pre>
2041</div></div>
2042<p>or, if you want to check out all of the index, use <tt>-a</tt>.</p>
2043<p>NOTE! git-checkout-index normally refuses to overwrite old files, so
2044if you have an old version of the tree already checked out, you will
2045need to use the "-f" flag (<em>before</em> the "-a" flag or the filename) to
2046<em>force</em> the checkout.</p>
2047<p>Finally, there are a few odds and ends which are not purely moving
2048from one representation to the other:</p>
2049<h3>5) Tying it all together</h3>
2050<p>To commit a tree you have instantiated with "git-write-tree", you'd
2051create a "commit" object that refers to that tree and the history
2052behind it - most notably the "parent" commits that preceded it in
2053history.</p>
2054<p>Normally a "commit" has one parent: the previous state of the tree
2055before a certain change was made. However, sometimes it can have two
2056or more parent commits, in which case we call it a "merge", due to the
2057fact that such a commit brings together ("merges") two or more
2058previous states represented by other commits.</p>
2059<p>In other words, while a "tree" represents a particular directory state
2060of a working directory, a "commit" represents that state in "time",
2061and explains how we got there.</p>
2062<p>You create a commit object by giving it the tree that describes the
2063state at the time of the commit, and a list of parents:</p>
2064<div class="literalblock">
2065<div class="content">
2066<pre><tt>git-commit-tree &lt;tree&gt; -p &lt;parent&gt; [-p &lt;parent2&gt; ..]</tt></pre>
2067</div></div>
2068<p>and then giving the reason for the commit on stdin (either through
2069redirection from a pipe or file, or by just typing it at the tty).</p>
2070<p>git-commit-tree will return the name of the object that represents
2071that commit, and you should save it away for later use. Normally,
2072you'd commit a new <tt>HEAD</tt> state, and while git doesn't care where you
2073save the note about that state, in practice we tend to just write the
2074result to the file pointed at by <tt>.git/HEAD</tt>, so that we can always see
2075what the last committed state was.</p>
2076<p>Here is an ASCII art by Jon Loeliger that illustrates how
2077various pieces fit together.</p>
2078<div class="listingblock">
2079<div class="content">
2080<pre><tt>
2081 commit-tree
2082 commit obj
2083 +----+
2084 | |
2085 | |
2086 V V
2087 +-----------+
2088 | Object DB |
2089 | Backing |
2090 | Store |
2091 +-----------+
2092 ^
2093 write-tree | |
2094 tree obj | |
2095 | | read-tree
2096 | | tree obj
2097 V
2098 +-----------+
2099 | Index |
2100 | "cache" |
2101 +-----------+
2102 update-index ^
2103 blob obj | |
2104 | |
2105 checkout-index -u | | checkout-index
2106 stat | | blob obj
2107 V
2108 +-----------+
2109 | Working |
2110 | Directory |
2111 +-----------+
2112</tt></pre>
2113</div></div>
2114<h3>6) Examining the data</h3>
2115<p>You can examine the data represented in the object database and the
2116index with various helper tools. For every object, you can use
2117<a href="git-cat-file.html">git-cat-file(1)</a> to examine details about the
2118object:</p>
2119<div class="literalblock">
2120<div class="content">
2121<pre><tt>git-cat-file -t &lt;objectname&gt;</tt></pre>
2122</div></div>
2123<p>shows the type of the object, and once you have the type (which is
2124usually implicit in where you find the object), you can use</p>
2125<div class="literalblock">
2126<div class="content">
2127<pre><tt>git-cat-file blob|tree|commit|tag &lt;objectname&gt;</tt></pre>
2128</div></div>
2129<p>to show its contents. NOTE! Trees have binary content, and as a result
2130there is a special helper for showing that content, called
2131<tt>git-ls-tree</tt>, which turns the binary content into a more easily
2132readable form.</p>
2133<p>It's especially instructive to look at "commit" objects, since those
2134tend to be small and fairly self-explanatory. In particular, if you
2135follow the convention of having the top commit name in <tt>.git/HEAD</tt>,
2136you can do</p>
2137<div class="literalblock">
2138<div class="content">
2139<pre><tt>git-cat-file commit HEAD</tt></pre>
2140</div></div>
2141<p>to see what the top commit was.</p>
2142<h3>7) Merging multiple trees</h3>
2143<p>Git helps you do a three-way merge, which you can expand to n-way by
2144repeating the merge procedure arbitrary times until you finally
2145"commit" the state. The normal situation is that you'd only do one
2146three-way merge (two parents), and commit it, but if you like to, you
2147can do multiple parents in one go.</p>
2148<p>To do a three-way merge, you need the two sets of "commit" objects
2149that you want to merge, use those to find the closest common parent (a
2150third "commit" object), and then use those commit objects to find the
2151state of the directory ("tree" object) at these points.</p>
2152<p>To get the "base" for the merge, you first look up the common parent
2153of two commits with</p>
2154<div class="literalblock">
2155<div class="content">
2156<pre><tt>git-merge-base &lt;commit1&gt; &lt;commit2&gt;</tt></pre>
2157</div></div>
2158<p>which will return you the commit they are both based on. You should
2159now look up the "tree" objects of those commits, which you can easily
2160do with (for example)</p>
2161<div class="literalblock">
2162<div class="content">
2163<pre><tt>git-cat-file commit &lt;commitname&gt; | head -1</tt></pre>
2164</div></div>
2165<p>since the tree object information is always the first line in a commit
2166object.</p>
2167<p>Once you know the three trees you are going to merge (the one
2168"original" tree, aka the common case, and the two "result" trees, aka
2169the branches you want to merge), you do a "merge" read into the
2170index. This will complain if it has to throw away your old index contents, so you should
2171make sure that you've committed those - in fact you would normally
2172always do a merge against your last commit (which should thus match
2173what you have in your current index anyway).</p>
2174<p>To do the merge, do</p>
2175<div class="literalblock">
2176<div class="content">
2177<pre><tt>git-read-tree -m -u &lt;origtree&gt; &lt;yourtree&gt; &lt;targettree&gt;</tt></pre>
2178</div></div>
2179<p>which will do all trivial merge operations for you directly in the
2180index file, and you can just write the result out with
2181<tt>git-write-tree</tt>.</p>
2182<p>Historical note. We did not have <tt>-u</tt> facility when this
2183section was first written, so we used to warn that
2184the merge is done in the index file, not in your
2185working tree, and your working tree will not match your
2186index after this step.
2187This is no longer true. The above command, thanks to <tt>-u</tt>
2188option, updates your working tree with the merge results for
2189paths that have been trivially merged.</p>
2190<h3>8) Merging multiple trees, continued</h3>
2191<p>Sadly, many merges aren't trivial. If there are files that have
2192been added.moved or removed, or if both branches have modified the
2193same file, you will be left with an index tree that contains "merge
2194entries" in it. Such an index tree can <em>NOT</em> be written out to a tree
2195object, and you will have to resolve any such merge clashes using
2196other tools before you can write out the result.</p>
2197<p>You can examine such index state with <tt>git-ls-files --unmerged</tt>
2198command. An example:</p>
2199<div class="listingblock">
2200<div class="content">
2201<pre><tt>$ git-read-tree -m $orig HEAD $target
2202$ git-ls-files --unmerged
2203100644 263414f423d0e4d70dae8fe53fa34614ff3e2860 1 hello.c
2204100644 06fa6a24256dc7e560efa5687fa84b51f0263c3a 2 hello.c
2205100644 cc44c73eb783565da5831b4d820c962954019b69 3 hello.c</tt></pre>
2206</div></div>
2207<p>Each line of the <tt>git-ls-files --unmerged</tt> output begins with
2208the blob mode bits, blob SHA1, <em>stage number</em>, and the
2209filename. The <em>stage number</em> is git's way to say which tree it
2210came from: stage 1 corresponds to <tt>$orig</tt> tree, stage 2 <tt>HEAD</tt>
2211tree, and stage3 <tt>$target</tt> tree.</p>
2212<p>Earlier we said that trivial merges are done inside
2213<tt>git-read-tree -m</tt>. For example, if the file did not change
2214from <tt>$orig</tt> to <tt>HEAD</tt> nor <tt>$target</tt>, or if the file changed
2215from <tt>$orig</tt> to <tt>HEAD</tt> and <tt>$orig</tt> to <tt>$target</tt> the same way,
2216obviously the final outcome is what is in <tt>HEAD</tt>. What the
2217above example shows is that file <tt>hello.c</tt> was changed from
2218<tt>$orig</tt> to <tt>HEAD</tt> and <tt>$orig</tt> to <tt>$target</tt> in a different way.
2219You could resolve this by running your favorite 3-way merge
2220program, e.g. <tt>diff3</tt> or <tt>merge</tt>, on the blob objects from
2221these three stages yourself, like this:</p>
2222<div class="listingblock">
2223<div class="content">
2224<pre><tt>$ git-cat-file blob 263414f... &gt;hello.c~1
2225$ git-cat-file blob 06fa6a2... &gt;hello.c~2
2226$ git-cat-file blob cc44c73... &gt;hello.c~3
2227$ merge hello.c~2 hello.c~1 hello.c~3</tt></pre>
2228</div></div>
2229<p>This would leave the merge result in <tt>hello.c~2</tt> file, along
2230with conflict markers if there are conflicts. After verifying
2231the merge result makes sense, you can tell git what the final
2232merge result for this file is by:</p>
2233<div class="literalblock">
2234<div class="content">
2235<pre><tt>mv -f hello.c~2 hello.c
2236git-update-index hello.c</tt></pre>
2237</div></div>
2238<p>When a path is in unmerged state, running <tt>git-update-index</tt> for
2239that path tells git to mark the path resolved.</p>
2240<p>The above is the description of a git merge at the lowest level,
2241to help you understand what conceptually happens under the hood.
2242In practice, nobody, not even git itself, uses three <tt>git-cat-file</tt>
2243for this. There is <tt>git-merge-index</tt> program that extracts the
2244stages to temporary files and calls a "merge" script on it:</p>
2245<div class="literalblock">
2246<div class="content">
2247<pre><tt>git-merge-index git-merge-one-file hello.c</tt></pre>
2248</div></div>
2249<p>and that is what higher level <tt>git resolve</tt> is implemented with.</p>
2250</div>
2251<h2>Authors</h2>
2252<div class="sectionbody">
2253<ul>
2254<li>
2255<p>
2256git's founding father is Linus Torvalds &lt;torvalds@osdl.org&gt;.
2257</p>
2258</li>
2259<li>
2260<p>
2261The current git nurse is Junio C Hamano &lt;junkio@cox.net&gt;.
2262</p>
2263</li>
2264<li>
2265<p>
2266The git potty was written by Andres Ericsson &lt;ae@op5.se&gt;.
2267</p>
2268</li>
2269<li>
2270<p>
2271General upbringing is handled by the git-list &lt;git@vger.kernel.org&gt;.
2272</p>
2273</li>
2274</ul>
2275</div>
2276<h2>Documentation</h2>
2277<div class="sectionbody">
2278<p>The documentation for git suite was started by David Greaves
2279&lt;david@dgreaves.com&gt;, and later enhanced greatly by the
2280contributors on the git-list &lt;git@vger.kernel.org&gt;.</p>
2281</div>
2282<h2>GIT</h2>
2283<div class="sectionbody">
2284<p>Part of the <a href="git.html">git(7)</a> suite</p>
2285</div>
2286<div id="footer">
2287<div id="footer-text">
Junio C Hamanodb450ba2007-01-21 08:57:142288Last updated 21-Jan-2007 08:57:05 UTC
Junio C Hamano1a4e8412005-12-27 08:17:232289</div>
2290</div>
2291</body>
2292</html>