Reference documentation for the core git commands.
[git.git] / Documentation / core-git.txt
1 This file contains reference information for the core git commands.
2 It is actually based on the source from Petr Baudis' tree and may
3 therefore contain a few 'extras' that may or may not make it upstream.
4
5 The README contains much useful definition and clarification info -
6 read that first.  And of the commands, I suggest reading
7 'update-cache' and 'read-tree' first - I wish I had!
8
9 Thanks to original email authors and proof readers esp Junio C Hamano
10 <junkio@cox.net>
11
12 David Greaves <david@dgreaves.com>
13 24/4/05
14
15 Identifier terminology used:
16
17 <object>
18         Indicates any object sha1 identifier
19
20 <blob>
21         Indicates a blob object sha1 identifier
22
23 <tree>
24         Indicates a tree object sha1 identifier
25
26 <commit>
27         Indicates a commit object sha1 identifier
28
29 <tree/commit>
30         Indicates a tree or commit object sha1 identifier (usually
31         because the command can read the <tree> a <commit> contains).
32         [Eventually may be replaced with <tree> if <tree> means
33         <tree/commit> in all commands]
34
35 <type>
36         Indicates that an object type is required.
37         Currently one of: blob/tree/commit
38
39 <file>
40         Indicates a filename - often includes leading path
41
42 <path>
43         Indicates the path of a file (is this ever useful?)
44
45
46
47 ################################################################
48 cat-file
49         cat-file (-t | <type>) <object>
50
51 Provide contents or type of objects in the repository. The type is
52 required if -t is not being used to find the object type.
53
54 <object>
55         The sha1 identifier of the object.
56
57 -t
58         show the object type identified by <object>
59
60 <type>
61         One of: blob/tree/commit
62
63 Output
64
65 If -t is specified, one of:
66         blob/tree/commit
67
68 Otherwise the raw (though uncompressed) contents of the <object> will
69 be returned.
70
71
72 ################################################################
73 check-files
74         check-files <file>...
75
76 Check that a list of files are up-to-date between the filesystem and
77 the cache. Used to verify a patch target before doing a patch.
78
79 Files that do not exist on the filesystem are considered up-to-date
80 (whether or not they are in the cache).
81
82 Emits an error message on failure.
83 preparing to update existing file <file> not in cache
84           <file> exists but is not in the cache
85
86 preparing to update file <file> not uptodate in cache
87           <file> on disk is not up-to-date with the cache
88
89 exits with a status code indicating success if all files are
90 up-to-date.
91
92 see also: update-cache
93
94
95 ################################################################
96 checkout-cache
97         checkout-cache [-q] [-a] [-f] [-n] [--prefix=<string>]
98                        [--] <file>...
99
100 Will copy all files listed from the cache to the working directory
101 (not overwriting existing files). Note that the file contents are
102 restored - NOT the file permissions.
103 ??? l 58 checkout-cache.c says restore executable bit.
104
105 -q
106         be quiet if files exist or are not in the cache
107
108 -f
109         forces overwrite of existing files
110
111 -a
112         checks out all files in the cache (will then continue to
113         process listed files).
114 -n
115         Don't checkout new files, only refresh files already checked
116         out.
117
118 --prefix=<string>
119         When creating files, prepend <string> (usually a directory
120         including a trailing /)
121
122 --
123         Do not interpret any more arguments as options.
124
125 Note that the order of the flags matters:
126
127         checkout-cache -a -f file.c
128
129 will first check out all files listed in the cache (but not overwrite
130 any old ones), and then force-checkout file.c a second time (ie that
131 one _will_ overwrite any old contents with the same filename).
132
133 Also, just doing "checkout-cache" does nothing. You probably meant
134 "checkout-cache -a". And if you want to force it, you want
135 "checkout-cache -f -a".
136
137 Intuitiveness is not the goal here. Repeatability is. The reason for
138 the "no arguments means no work" thing is that from scripts you are
139 supposed to be able to do things like
140
141         find . -name '*.h' -print0 | xargs -0 checkout-cache -f --
142
143 which will force all existing *.h files to be replaced with their
144 cached copies. If an empty command line implied "all", then this would
145 force-refresh everything in the cache, which was not the point.
146
147 To update and refresh only the files already checked out:
148
149    checkout-cache -n -f -a && update-cache --ignore-missing --refresh
150
151 Oh, and the "--" is just a good idea when you know the rest will be
152 filenames. Just so that you wouldn't have a filename of "-a" causing
153 problems (not possible in the above example, but get used to it in
154 scripting!).
155
156 The prefix ability basically makes it trivial to use checkout-cache as
157 a "export as tree" function. Just read the desired tree into the
158 index, and do a
159   
160         checkout-cache --prefix=export-dir/ -a
161   
162 and checkout-cache will "export" the cache into the specified
163 directory.
164   
165 NOTE! The final "/" is important. The exported name is literally just
166 prefixed with the specified string, so you can also do something like
167   
168         checkout-cache --prefix=.merged- Makefile
169   
170 to check out the currently cached copy of "Makefile" into the file
171 ".merged-Makefile".
172
173
174 ################################################################
175 commit-tree
176         commit-tree <tree> [-p <parent commit>]*   < changelog
177
178 Creates a new commit object based on the provided tree object and
179 emits the new commit object id on stdout. If no parent is given then
180 it is considered to be an initial tree.
181
182 A commit object usually has 1 parent (a commit after a change) or up
183 to 16 parents.  More than one parent represents a merge of branches
184 that led to them.
185
186 While a tree represents a particular directory state of a working
187 directory, a commit represents that state in "time", and explains how
188 to get there.
189
190 Normally a commit would identify a new "HEAD" state, and while git
191 doesn't care where you save the note about that state, in practice we
192 tend to just write the result to the file ".git/HEAD", so that we can
193 always see what the last committed state was.
194
195 Options
196
197 <tree>
198         An existing tree object
199
200 -p <parent commit>
201         Each -p indicates a the id of a parent commit object.
202         
203
204 Commit Information
205
206 A commit encapsulates:
207         all parent object ids
208         author name, email and date
209         committer name and email and the commit time.
210
211 If not provided, commit-tree uses your name, hostname and domain to
212 provide author and committer info. This can be overridden using the
213 following environment variables.
214         AUTHOR_NAME
215         AUTHOR_EMAIL
216         AUTHOR_DATE
217         COMMIT_AUTHOR_NAME
218         COMMIT_AUTHOR_EMAIL
219 (nb <,> and '\n's are stripped)
220
221 A commit comment is read from stdin (max 999 chars). If a changelog
222 entry is not provided via '<' redirection, commit-tree will just wait
223 for one to be entered and terminated with ^D
224
225 see also: write-tree
226
227
228 ################################################################
229 diff-cache
230         diff-cache [-p] [-r] [-z] [--cached] <tree/commit>
231
232 Compares the content and mode of the blobs found via a tree object
233 with the content of the current cache and, optionally ignoring the
234 stat state of the file on disk.
235
236 <tree/commit>
237         The id of a tree or commit object to diff against.
238
239 -p
240         generate patch (see section on generating patches)
241
242 -r
243         recurse
244
245 -z
246         \0 line termination on output
247
248 --cached
249         do not consider the on-disk file at all
250
251 Output format:
252
253 See "Output format from diff-cache, diff-tree and show-diff" section.
254
255 Operating Modes
256
257 You can choose whether you want to trust the index file entirely
258 (using the "--cached" flag) or ask the diff logic to show any files
259 that don't match the stat state as being "tentatively changed".  Both
260 of these operations are very useful indeed.
261
262 Cached Mode
263
264 If --cached is specified, it allows you to ask:
265         show me the differences between HEAD and the current index
266         contents (the ones I'd write with a "write-tree")
267
268 For example, let's say that you have worked on your index file, and are
269 ready to commit. You want to see eactly _what_ you are going to commit is
270 without having to write a new tree object and compare it that way, and to
271 do that, you just do
272
273         diff-cache --cached $(cat .git/HEAD)
274
275 Example: let's say I had renamed "commit.c" to "git-commit.c", and I had 
276 done an "upate-cache" to make that effective in the index file. 
277 "show-diff" wouldn't show anything at all, since the index file matches 
278 my working directory. But doing a diff-cache does:
279         torvalds@ppc970:~/git> diff-cache --cached $(cat .git/HEAD)
280         -100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        commit.c
281         +100644 blob    4161aecc6700a2eb579e842af0b7f22b98443f74        git-commit.c
282
283 And as you can see, the output matches "diff-tree -r" output (we
284 always do equivalent of "-r", since the index is flat).
285 You can trivially see that the above is a rename.
286
287 In fact, "diff-cache --cached" _should_ always be entirely equivalent to
288 actually doing a "write-tree" and comparing that. Except this one is much
289 nicer for the case where you just want to check where you are.
290
291 So doing a "diff-cache --cached" is basically very useful when you are 
292 asking yourself "what have I already marked for being committed, and 
293 what's the difference to a previous tree".
294
295 Non-cached Mode
296
297 The "non-cached" mode takes a different approach, and is potentially
298 the even more useful of the two in that what it does can't be emulated
299 with a "write-tree + diff-tree". Thus that's the default mode.  The
300 non-cached version asks the question
301
302    "show me the differences between HEAD and the currently checked out 
303     tree - index contents _and_ files that aren't up-to-date"
304
305 which is obviously a very useful question too, since that tells you what
306 you _could_ commit. Again, the output matches the "diff-tree -r" output to
307 a tee, but with a twist.
308
309 The twist is that if some file doesn't match the cache, we don't have a
310 backing store thing for it, and we use the magic "all-zero" sha1 to show
311 that. So let's say that you have edited "kernel/sched.c", but have not
312 actually done an update-cache on it yet - there is no "object" associated
313 with the new state, and you get:
314
315         torvalds@ppc970:~/v2.6/linux> diff-cache $(cat .git/HEAD )
316         *100644->100664 blob    7476bbcfe5ef5a1dd87d745f298b831143e4d77e->0000000000000000000000000000000000000000      kernel/sched.c
317
318 ie it shows that the tree has changed, and that "kernel/sched.c" has is
319 not up-to-date and may contain new stuff. The all-zero sha1 means that to
320 get the real diff, you need to look at the object in the working directory
321 directly rather than do an object-to-object diff.
322
323 NOTE! As with other commands of this type, "diff-cache" does not actually 
324 look at the contents of the file at all. So maybe "kernel/sched.c" hasn't 
325 actually changed, and it's just that you touched it. In either case, it's 
326 a note that you need to upate-cache it to make the cache be in sync.
327
328 NOTE 2! You can have a mixture of files show up as "has been updated" and
329 "is still dirty in the working directory" together. You can always tell
330 which file is in which state, since the "has been updated" ones show a
331 valid sha1, and the "not in sync with the index" ones will always have the
332 special all-zero sha1.
333
334 ################################################################
335 diff-tree
336         diff-tree [-p] [-r] [-z] <tree/commit> <tree/commit> [<pattern>]*
337
338 Compares the content and mode of the blobs found via two tree objects.
339
340 Note that diff-tree can use the tree encapsulated in a commit object.
341
342 <tree sha1>
343         The id of a tree or commit object.
344
345 <pattern>
346
347         If provided, the results are limited to a subset of files
348         matching one of these prefix strings.
349         ie file matches /^<pattern1>|<pattern2>|.../
350         Note that pattern does not provide any wildcard or regexp features.
351
352 -p
353         generate patch (see section on generating patches)
354
355 -r
356         recurse
357
358 -z
359         \0 line termination on output
360
361 Limiting Output
362
363 If you're only interested in differences in a subset of files, for
364 example some architecture-specific files, you might do:
365
366         diff-tree -r <tree/commit> <tree/commit> arch/ia64 include/asm-ia64
367
368 and it will only show you what changed in those two directories.
369
370 Or if you are searching for what changed in just kernel/sched.c, just do
371
372         diff-tree -r <tree/commit> <tree/commit> kernel/sched.c
373
374 and it will ignore all differences to other files.
375
376 The pattern is always the prefix, and is matched exactly (ie there are no
377 wildcards - although matching a directory, which it does support, can
378 obviously be seen as a "wildcard" for all the files under that directory).
379
380 Output format:
381
382 See "Output format from diff-cache, diff-tree and show-diff" section.
383
384 An example of normal usage is:
385
386         torvalds@ppc970:~/git> diff-tree 5319e4d609cdd282069cc4dce33c1db559539b03 b4e628ea30d5ab3606119d2ea5caeab141d38df7
387         *100664->100664 blob    ac348b7d5278e9d04e3a1cd417389379c32b014f->a01513ed4d4d565911a60981bfb4173311ba3688      fsck-cache.c
388
389 which tells you that the last commit changed just one file (it's from
390 this one:
391
392         commit 3c6f7ca19ad4043e9e72fa94106f352897e651a8
393         tree 5319e4d609cdd282069cc4dce33c1db559539b03
394         parent b4e628ea30d5ab3606119d2ea5caeab141d38df7
395         author Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
396         committer Linus Torvalds <torvalds@ppc970.osdl.org> Sat Apr 9 12:02:30 2005
397
398         Make "fsck-cache" print out all the root commits it finds.
399
400         Once I do the reference tracking, I'll also make it print out all the
401         HEAD commits it finds, which is even more interesting.
402
403 in case you care).
404
405 ################################################################
406 diff-tree-helper
407         diff-tree-helper [-z]
408
409 Reads output from diff-cache, diff-tree and show-diff and
410 generates patch format output.
411
412 -z
413         \0 line termination on input
414
415 See also the section on generating patches.
416
417 ################################################################
418 fsck-cache
419         fsck-cache [[--unreachable] <commit>*]
420
421 Verifies the connectivity and validity of the objects in the database.
422
423 <commit>
424         A commit object to treat as the head of an unreachability
425         trace
426
427 --unreachable
428         print out objects that exist but that aren't readable from any
429         of the specified root nodes
430
431 It tests SHA1 and general object sanity, but it does full tracking of
432 the resulting reachability and everything else. It prints out any
433 corruption it finds (missing or bad objects), and if you use the
434 "--unreachable" flag it will also print out objects that exist but
435 that aren't readable from any of the specified root nodes.
436
437 So for example
438
439         fsck-cache --unreachable $(cat .git/HEAD)
440
441 or, for Cogito users:
442
443         fsck-cache --unreachable $(cat .git/heads/*)
444
445 will do quite a _lot_ of verification on the tree. There are a few
446 extra validity tests to be added (make sure that tree objects are
447 sorted properly etc), but on the whole if "fsck-cache" is happy, you
448 do have a valid tree.
449
450 Any corrupt objects you will have to find in backups or other archives
451 (ie you can just remove them and do an "rsync" with some other site in
452 the hopes that somebody else has the object you have corrupted).
453
454 Of course, "valid tree" doesn't mean that it wasn't generated by some
455 evil person, and the end result might be crap. Git is a revision
456 tracking system, not a quality assurance system ;)
457
458 Extracted Diagnostics
459
460 expect dangling commits - potential heads - due to lack of head information
461         You haven't specified any nodes as heads so it won't be
462         possible to differentiate between un-parented commits and
463         root nodes.
464
465 missing sha1 directory '<dir>'
466         The directory holding the sha1 objects is missing.
467
468 unreachable <type> <object>
469         The <type> object <object>, isn't actually referred to directly
470         or indirectly in any of the trees or commits seen. This can
471         mean that there's another root na SHA1_ode that you're not specifying
472         or that the tree is corrupt. If you haven't missed a root node
473         then you might as well delete unreachable nodes since they
474         can't be used.
475
476 missing <type> <object>
477         The <type> object <object>, is referred to but isn't present in
478         the database.
479
480 dangling <type> <object>
481         The <type> object <object>, is present in the database but never
482         _directly_ used. A dangling commit could be a root node.
483
484 warning: fsck-cache: tree <tree> has full pathnames in it
485         And it shouldn't...
486
487 sha1 mismatch <object>
488         The database has an object who's sha1 doesn't match the
489         database value.
490         This indicates a ??serious?? data integrity problem.
491         (note: this error occured during early git development when
492         the database format changed.)
493
494 Environment Variables
495
496 SHA1_FILE_DIRECTORY
497         used to specify the object database root (usually .git/objects)
498
499 ################################################################
500 git-export
501         git-export top [base]
502
503 probably deprecated:
504 On Wed, 20 Apr 2005, Petr Baudis wrote:
505 >> I will probably not buy git-export, though. (That is, it is merged, but
506 >> I won't make git frontend for it.) My "git export" already does
507 >> something different, but more importantly, "git patch" of mine already
508 >> does effectively the same thing as you do, just for a single patch; so I
509 >> will probably just extend it to do it for an (a,b] range of patches.
510
511
512 That's fine. It was a quick hack, just to show that if somebody wants to, 
513 the data is trivially exportable.
514
515                 Linus
516
517 Although in Linus' distribution, git-export is not part of 'core' git.
518
519 ################################################################
520 init-db
521         init-db
522
523 This simply creates an empty git object database - basically a .git
524 directory.
525
526 If the object storage directory is specified via the
527 SHA1_FILE_DIRECTORY environment variable then the sha1 directories are
528 created underneath - otherwise the default .git/objects directory is
529 used.
530
531 init-db won't hurt an existing repository.
532
533
534 ################################################################
535 ls-tree
536         ls-tree [-r] [-z] <tree/commit>
537
538 convert the tree object to a human readable (and script
539 processable) form.
540
541 <tree/commit>
542         Id of a tree or commit object.
543 -r
544         recurse into sub-trees
545
546 -z
547         \0 line termination on output
548
549 Output Format
550 <mode>\t        <type>\t        <object>\t      <path><file>    
551
552
553 ################################################################
554 merge-base
555         merge-base <commit> <commit>
556
557 merge-base finds as good a common ancestor as possible. Given a
558 selection of equally good common ancestors it should not be relied on
559 to decide in any particular way.
560
561 The merge-base algorithm is still in flux - use the source...
562
563
564 ################################################################
565 merge-cache
566         merge-cache <merge-program> (-a | -- | <file>*) 
567
568 This looks up the <file>(s) in the cache and, if there are any merge
569 entries, unpacks all of them (which may be just one file, of course)
570 into up to three separate temporary files, and then executes the
571 supplied <merge-program> with those three files as arguments 1,2,3
572 (empty argument if no file), and <file> as argument 4.
573
574 --
575         Interpret all future arguments as filenames
576
577 -a
578         Run merge against all files in the cache that need merging.
579
580 If merge-cache is called with multiple <file>s (or -a) then it
581 processes them in turn only stopping if merge returns a non-zero exit
582 code.
583
584 Typically this is run with the a script calling the merge command from
585 the RCS package.
586
587 A sample script called git-merge-one-file-script is included in the
588 ditribution.
589
590 ALERT ALERT ALERT! The git "merge object order" is different from the
591 RCS "merge" program merge object order. In the above ordering, the
592 original is first. But the argument order to the 3-way merge program
593 "merge" is to have the original in the middle. Don't ask me why.
594
595 Examples:
596
597         torvalds@ppc970:~/merge-test> merge-cache cat MM
598         This is MM from the original tree.                      # original
599         This is modified MM in the branch A.                    # merge1
600         This is modified MM in the branch B.                    # merge2
601         This is modified MM in the branch B.                    # current contents
602
603 or 
604
605         torvalds@ppc970:~/merge-test> merge-cache cat AA MM
606         cat: : No such file or directory
607         This is added AA in the branch A.
608         This is added AA in the branch B.
609         This is added AA in the branch B.
610         fatal: merge program failed
611
612 where the latter example shows how "merge-cache" will stop trying to
613 merge once anything has returned an error (ie "cat" returned an error
614 for the AA file, because it didn't exist in the original, and thus
615 "merge-cache" didn't even try to merge the MM thing).
616
617
618 ################################################################
619 read-tree
620         read-tree (<tree/commit> | -m <tree/commit1> [<tree/commit2> <tree/commit3>])"
621
622 Reads the tree information given by <tree> into the directory cache,
623 but does not actually _update_ any of the files it "caches". (see:
624 checkout-cache)
625
626 Optionally, it can merge a tree into the cache or perform a 3-way
627 merge.
628
629 Trivial merges are done by read-tree itself.  Only conflicting paths
630 will be in unmerged state when read-tree returns.
631
632 -m
633         Perform a merge, not just a read
634
635 <tree#>
636         The id of the tree object(s) to be read/merged.
637
638
639 Merging
640 If -m is specified, read-tree performs 2 kinds of merge, a single tree
641 merge if only 1 tree is given or a 3-way merge if 3 trees are
642 provided.
643
644 Single Tree Merge
645 If only 1 tree is specified, read-tree operates as if the user did not
646 specify "-m", except that if the original cache has an entry for a
647 given pathname; and the contents of the path matches with the tree
648 being read, the stat info from the cache is used. (In other words, the
649 cache's stat()s take precedence over the merged tree's)
650
651 That means that if you do a "read-tree -m <newtree>" followed by a
652 "checkout-cache -f -a", the checkout-cache only checks out the stuff
653 that really changed.
654
655 This is used to avoid unnecessary false hits when show-diff is
656 run after read-tree.
657
658 3-Way Merge
659 Each "index" entry has two bits worth of "stage" state. stage 0 is the
660 normal one, and is the only one you'd see in any kind of normal use.
661
662 However, when you do "read-tree" with multiple trees, the "stage"
663 starts out at 0, but increments for each tree you read. And in
664 particular, the "-m" flag means "start at stage 1" instead.
665
666 This means that you can do
667
668         read-tree -m <tree1> <tree2> <tree3>
669
670 and you will end up with an index with all of the <tree1> entries in
671 "stage1", all of the <tree2> entries in "stage2" and all of the
672 <tree3> entries in "stage3".
673
674 Furthermore, "read-tree" has special-case logic that says: if you see
675 a file that matches in all respects in the following states, it
676 "collapses" back to "stage0":
677
678    - stage 2 and 3 are the same; take one or the other (it makes no
679      difference - the same work has been done on stage 2 and 3)
680
681    - stage 1 and stage 2 are the same and stage 3 is different; take
682      stage 3 (some work has been done on stage 3)
683
684    - stage 1 and stage 3 are the same and stage 2 is different take
685      stage 2 (some work has been done on stage 2)
686
687 Write-tree refuses to write a nonsensical tree, so write-tree will
688 complain about unmerged entries if it sees a single entry that is not
689 stage 0".
690
691 Ok, this all sounds like a collection of totally nonsensical rules,
692 but it's actually exactly what you want in order to do a fast
693 merge. The different stages represent the "result tree" (stage 0, aka
694 "merged"), the original tree (stage 1, aka "orig"), and the two trees
695 you are trying to merge (stage 2 and 3 respectively).
696
697 In fact, the way "read-tree" works, it's entirely agnostic about how
698 you assign the stages, and you could really assign them any which way,
699 and the above is just a suggested way to do it (except since
700 "write-tree" refuses to write anything but stage0 entries, it makes
701 sense to always consider stage 0 to be the "full merge" state).
702
703 So what happens? Try it out. Select the original tree, and two trees
704 to merge, and look how it works:
705
706  - if a file exists in identical format in all three trees, it will 
707    automatically collapse to "merged" state by the new read-tree.
708
709  - a file that has _any_ difference what-so-ever in the three trees
710    will stay as separate entries in the index. It's up to "script
711    policy" to determine how to remove the non-0 stages, and insert a
712    merged version.  But since the index is always sorted, they're easy
713    to find: they'll be clustered together.
714
715  - the index file saves and restores with all this information, so you
716    can merge things incrementally, but as long as it has entries in
717    stages 1/2/3 (ie "unmerged entries") you can't write the result.
718
719 So now the merge algorithm ends up being really simple:
720
721  - you walk the index in order, and ignore all entries of stage 0,
722    since they've already been done.
723
724  - if you find a "stage1", but no matching "stage2" or "stage3", you
725    know it's been removed from both trees (it only existed in the
726    original tree), and you remove that entry.  - if you find a
727    matching "stage2" and "stage3" tree, you remove one of them, and
728    turn the other into a "stage0" entry. Remove any matching "stage1"
729    entry if it exists too.  .. all the normal trivial rules ..
730
731 Incidentally - it also means that you don't even have to have a separate 
732 subdirectory for this. All the information literally is in the index file, 
733 which is a temporary thing anyway. There is no need to worry about what is in 
734 the working directory, since it is never shown and never used.
735
736 see also:
737 write-tree
738 show-files
739
740
741 ################################################################
742 rev-list <commit>
743
744 Lists commit objects in reverse chronological order starting at the
745 given commit, taking ancestry relationship into account.  This is
746 useful to produce human-readable log output.
747
748
749 ################################################################
750 rev-tree
751         rev-tree [--edges] [--cache <cache-file>] [^]<commit> [[^]<commit>]
752
753 Provides the revision tree for one or more commits.
754
755 --edges
756         Show edges (ie places where the marking changes between parent
757         and child)
758
759 --cache <cache-file>
760         Use the specified file as a cache. [Not implemented yet]
761
762 [^]<commit>
763         The commit id to trace (a leading caret means to ignore this
764         commit-id and below)
765
766 Output:
767 <date> <commit>:<flags> [<parent-commit>:<flags> ]*
768
769 <date>
770         Date in 'seconds since epoch'
771
772 <commit>
773         id of commit object
774
775 <parent-commit>
776         id of each parent commit object (>1 indicates a merge)
777
778 <flags>
779
780         The flags are read as a bitmask representing each commit
781         provided on the commandline. eg: given the command:
782
783                  $ rev-tree <com1> <com2> <com3>
784
785         The output:
786
787             <date> <commit>:5
788
789          means that <commit> is reachable from <com1>(1) and <com3>(4)
790         
791 A revtree can get quite large. rev-tree will eventually allow you to
792 cache previous state so that you don't have to follow the whole thing
793 down.
794
795 So the change difference between two commits is literally
796
797         rev-tree [commit-id1]  > commit1-revtree
798         rev-tree [commit-id2]  > commit2-revtree
799         join -t : commit1-revtree commit2-revtree > common-revisions
800
801 (this is also how to find the most common parent - you'd look at just
802 the head revisions - the ones that aren't referred to by other
803 revisions - in "common-revision", and figure out the best one. I
804 think.)
805
806
807 ################################################################
808 show-diff
809         show-diff [-p] [-q] [-s] [-z] [paths...]
810
811 Compares the files in the working tree and the cache.  When paths
812 are specified, compares only those named paths.  Otherwise all
813 entries in the cache are compared.  The output format is the
814 same as diff-cache and diff-tree.
815
816 -p
817         generate patch (see section on generating patches)
818
819 -q
820         Remain silent even on nonexisting files
821
822 -s
823         Does not do anything other than what -q does.
824
825 Output format:
826
827 See "Output format from diff-cache, diff-tree and show-diff" section.
828
829 ################################################################
830 show-files
831         show-files [-z] [-t]
832                 (--[cached|deleted|others|ignored|stage|unmerged])*
833                 (-[c|d|o|i|s|u])*
834                 [-x <pattern>|--exclude=<pattern>]
835                 [-X <file>|--exclude-from=<file>]
836
837 This merges the file listing in the directory cache index with the
838 actual working directory list, and shows different combinations of the
839 two.
840
841 One or more of the options below may be used to determine the files
842 shown:
843
844 -c|--cached
845         Show cached files in the output (default)
846
847 -d|--deleted
848         Show deleted files in the output
849
850 -o|--others
851         Show other files in the output
852
853 -i|--ignored
854         Show ignored files in the output
855         Note the this also reverses any exclude list present.
856
857 -s|--stage
858         Show stage files in the output
859
860 -u|--unmerged
861         Show unmerged files in the output (forces --stage)
862
863 #-t [not in Linus' tree (yet?)]
864 #       Identify the file status with the following tags (followed by
865 #       a space) at the start of each line:
866 #       H       cached
867 #       M       unmerged
868 #       R       removed/deleted
869 #       ?       other
870
871 -z
872         \0 line termination on output
873
874 -x|--exclude=<pattern>
875         Skips files matching pattern.
876         Note that pattern is a shell wildcard pattern.
877
878 -X|--exclude-from=<file>
879         exclude patterns are read from <file>; 1 per line.
880         Allows the use of the famous dontdiff file as follows to find
881         out about uncommitted files just as dontdiff is used with
882         the diff command:
883              show-files --others --exclude-from=dontdiff
884
885 Output
886 show files just outputs the filename unless --stage is specified in
887 which case it outputs:
888
889 [<tag> ]<mode> <object> <stage> <file>
890
891 show-files --unmerged" and "show-files --stage " can be used to examine
892 detailed information on unmerged paths.
893
894 For an unmerged path, instead of recording a single mode/SHA1 pair,
895 the dircache records up to three such pairs; one from tree O in stage
896 1, A in stage 2, and B in stage 3.  This information can be used by
897 the user (or Cogito) to see what should eventually be recorded at the
898 path. (see read-cache for more information on state)
899
900 see also:
901 read-cache
902
903
904 ################################################################
905 unpack-file
906         unpack-file <blob>
907
908 Creates a file holding the contents of the blob specified by sha1. It
909 returns the name of the temporary file in the following format:
910         .merge_file_XXXXX
911
912 <blob>
913         Must be a blob id
914
915 ################################################################
916 update-cache
917         update-cache [--add] [--remove] [--refresh [--ignore-missing]]
918                      [--cacheinfo <mode> <object> <path>]*
919                      [--] [<file>]*
920
921 Modifies the index or directory cache. Each file mentioned is updated
922 into the cache and any 'unmerged' or 'needs updating' state is
923 cleared.
924
925 The way update-cache handles files it is told about can be modified
926 using the various options:
927
928 --add
929         If a specified file isn't in the cache already then it's
930         added.
931         Default behaviour is to ignore new files.
932
933 --remove
934         If a specified file is in the cache but is missing then it's
935         removed.
936         Default behaviour is to ignore removed file.
937
938 --refresh
939         Looks at the current cache and checks to see if merges or
940         updates are needed by checking stat() information.
941
942 --ignore-missing
943         Ignores missing files during a --refresh
944
945 --cacheinfo <mode> <object> <path>
946         Directly insert the specified info into the cache.
947         
948 --
949         Do not interpret any more arguments as options.
950
951 <file>
952         Files to act on.
953         Note that files begining with '.' are discarded. This includes
954         "./file" and "dir/./file". If you don't want this, then use     
955         cleaner names.
956         The same applies to directories ending '/' and paths with '//'
957
958
959 Using --refresh
960
961 --refresh does not calculate a new sha1 file or bring the cache
962 up-to-date for mode/content changes. But what it _does_ do is to
963 "re-match" the stat information of a file with the cache, so that you
964 can refresh the cache for a file that hasn't been changed but where
965 the stat entry is out of date.
966
967 For example, you'd want to do this after doing a "read-tree", to link
968 up the stat cache details with the proper files.
969
970 Using --cacheinfo
971 --cacheinfo is used to register a file that is not in the current
972 working directory.  This is useful for minimum-checkout merging.
973
974 To pretend you have a file with mode and sha1 at path, say:
975
976  $ update-cache --cacheinfo mode sha1 path
977
978 To update and refresh only the files already checked out:
979
980    checkout-cache -n -f -a && update-cache --ignore-missing --refresh
981
982
983 ################################################################
984 write-tree
985         write-tree
986
987 Creates a tree object using the current cache.
988
989 The cache must be merged.
990
991 Conceptually, write-tree sync()s the current directory cache contents
992 into a set of tree files.
993 In order to have that match what is actually in your directory right
994 now, you need to have done a "update-cache" phase before you did the
995 "write-tree".
996
997
998 ################################################################
999
1000 Output format from diff-cache, diff-tree and show-diff.
1001
1002 These commands all compare two sets of things; what are
1003 compared are different:
1004
1005     diff-cache <tree/commit>
1006
1007         compares the <tree/commit> and the files on the filesystem.
1008
1009     diff-cache --cached <tree/commit>
1010
1011         compares the <tree/commit> and the cache.
1012
1013     diff-tree [-r] <tree/commit-1> <tree/commit-2> [paths...]
1014
1015         compares the trees named by the two arguments.
1016
1017     show-diff [paths...]
1018
1019         compares the cache and the files on the filesystem.
1020
1021 The following desription uses "old" and "new" to mean those
1022 compared entities.
1023
1024 For files in old but not in new (i.e. removed):
1025 -<mode> \t <type> \t <object> \t <path>
1026
1027 For files not in old but in new (i.e. added):
1028 +<mode> \t <type> \t <object> \t <path>
1029
1030 For files that differ:
1031 *<old-mode>-><new-mode> \t <type> \t <old-sha1>-><new-sha1> \t <path>
1032
1033 <new-sha1> is shown as all 0's if new is a file on the
1034 filesystem and it is out of sync with the cache.  Example:
1035
1036     *100644->100660 blob    5be4a414b32cf4204f889469942986d3d783da84->0000000000000000000000000000000000000000      file.c
1037
1038 ################################################################
1039
1040 Generating patches
1041
1042 When diff-cache, diff-tree, or show-diff are run with a -p
1043 option, they do not produce the output described in "Output
1044 format from diff-cache, diff-tree and show-diff" section.  It
1045 instead produces a patch file.
1046
1047 The patch generation can be customized at two levels.  This
1048 customization also applies to diff-tree-helper.
1049
1050 1. When the environment variable GIT_EXTERNAL_DIFF is not set,
1051    these commands internally invoke diff like this:
1052
1053    diff -L k/<path> -L l/<path> -pu <old> <new>
1054
1055    For added files, /dev/null is used for <old>.  For removed
1056    files, /dev/null is used for <new>
1057
1058    The first part of the above command-line can be customized via
1059    the environment variable GIT_DIFF_CMD.  For example, if you
1060    do not want to show the extra level of leading path, you can
1061    say this:
1062
1063    GIT_DIFF_CMD="diff -L'%s' -L'%s'" show-diff -p
1064
1065    Caution:  Do not use more than two '%s' in GIT_DIFF_CMD.
1066
1067    The diff formatting options can be customized via the
1068    environment variable GIT_DIFF_OPTS.  For example, if you
1069    prefer context diff:
1070
1071    GIT_DIFF_OPTS=-c diff-cache -p $(cat .git/HEAD)
1072
1073
1074 2. When the environment variable GIT_EXTERNAL_DIFF is set, the
1075    program named by it is called, instead of the diff invocation
1076    described above.
1077
1078    For a path that is added, removed, or modified,
1079    GIT_EXTERNAL_DIFF is called with 7 parameters:
1080
1081      path old-file old-hex old-mode new-file new-hex new-mode
1082
1083    where
1084      <old|new>-file are files GIT_EXTERNAL_DIFF can use to read the
1085                     contents of <old|ne>,
1086      <old|new>-hex are the 40-hexdigit SHA1 hashes,
1087      <old|new>-mode are the octal representation of the file modes.
1088
1089    The file parameters can point at the user's working file
1090    (e.g. new-file in show-diff), /dev/null (e.g. old-file when a
1091    new file is added), or a temporary file (e.g. old-file in the
1092    cache).  GIT_EXTERNAL_DIFF should not worry about
1093    unlinking the temporary file --- it is removed when
1094    GIT_EXTERNAL_DIFF exits.
1095
1096    For a path that is unmerged, GIT_EXTERNAL_DIFF is called with
1097    1 parameter, path.
1098
1099 ################################################################
1100
1101 Terminology: - see README for description
1102 Each line contains terms used interchangeably
1103
1104 object database, .git directory
1105 directory cache, index
1106 id, sha1, sha1-id, sha1 hash
1107 type, tag
1108 blob, blob object
1109 tree, tree object
1110 commit, commit object
1111 parent
1112 root object
1113 changeset
1114
1115
1116 git Environment Variables
1117 AUTHOR_NAME
1118 AUTHOR_EMAIL
1119 AUTHOR_DATE
1120 COMMIT_AUTHOR_NAME
1121 COMMIT_AUTHOR_EMAIL
1122 GIT_DIFF_CMD
1123 GIT_DIFF_OPTS
1124 GIT_EXTERNAL_DIFF
1125 GIT_INDEX_FILE
1126 SHA1_FILE_DIRECTORY
1127
1128