Documentation / core-git.txton commit Reference documentation for the core git commands. (c64b9b8)
   1This file contains reference information for the core git commands.
   2It is actually based on the source from Petr Baudis' tree and may
   3therefore contain a few 'extras' that may or may not make it upstream.
   4
   5The README contains much useful definition and clarification info -
   6read that first.  And of the commands, I suggest reading
   7'update-cache' and 'read-tree' first - I wish I had!
   8
   9Thanks to original email authors and proof readers esp Junio C Hamano
  10<junkio@cox.net>
  11
  12David Greaves <david@dgreaves.com>
  1324/4/05
  14
  15Identifier 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################################################################
  48cat-file
  49        cat-file (-t | <type>) <object>
  50
  51Provide contents or type of objects in the repository. The type is
  52required 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
  63Output
  64
  65If -t is specified, one of:
  66        blob/tree/commit
  67
  68Otherwise the raw (though uncompressed) contents of the <object> will
  69be returned.
  70
  71
  72################################################################
  73check-files
  74        check-files <file>...
  75
  76Check that a list of files are up-to-date between the filesystem and
  77the cache. Used to verify a patch target before doing a patch.
  78
  79Files that do not exist on the filesystem are considered up-to-date
  80(whether or not they are in the cache).
  81
  82Emits an error message on failure.
  83preparing to update existing file <file> not in cache
  84          <file> exists but is not in the cache
  85
  86preparing to update file <file> not uptodate in cache
  87          <file> on disk is not up-to-date with the cache
  88
  89exits with a status code indicating success if all files are
  90up-to-date.
  91
  92see also: update-cache
  93
  94
  95################################################################
  96checkout-cache
  97        checkout-cache [-q] [-a] [-f] [-n] [--prefix=<string>]
  98                       [--] <file>...
  99
 100Will copy all files listed from the cache to the working directory
 101(not overwriting existing files). Note that the file contents are
 102restored - 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
 125Note that the order of the flags matters:
 126
 127        checkout-cache -a -f file.c
 128
 129will first check out all files listed in the cache (but not overwrite
 130any old ones), and then force-checkout file.c a second time (ie that
 131one _will_ overwrite any old contents with the same filename).
 132
 133Also, 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
 137Intuitiveness is not the goal here. Repeatability is. The reason for
 138the "no arguments means no work" thing is that from scripts you are
 139supposed to be able to do things like
 140
 141        find . -name '*.h' -print0 | xargs -0 checkout-cache -f --
 142
 143which will force all existing *.h files to be replaced with their
 144cached copies. If an empty command line implied "all", then this would
 145force-refresh everything in the cache, which was not the point.
 146
 147To update and refresh only the files already checked out:
 148
 149   checkout-cache -n -f -a && update-cache --ignore-missing --refresh
 150
 151Oh, and the "--" is just a good idea when you know the rest will be
 152filenames. Just so that you wouldn't have a filename of "-a" causing
 153problems (not possible in the above example, but get used to it in
 154scripting!).
 155
 156The prefix ability basically makes it trivial to use checkout-cache as
 157a "export as tree" function. Just read the desired tree into the
 158index, and do a
 159  
 160        checkout-cache --prefix=export-dir/ -a
 161  
 162and checkout-cache will "export" the cache into the specified
 163directory.
 164  
 165NOTE! The final "/" is important. The exported name is literally just
 166prefixed with the specified string, so you can also do something like
 167  
 168        checkout-cache --prefix=.merged- Makefile
 169  
 170to check out the currently cached copy of "Makefile" into the file
 171".merged-Makefile".
 172
 173
 174################################################################
 175commit-tree
 176        commit-tree <tree> [-p <parent commit>]*   < changelog
 177
 178Creates a new commit object based on the provided tree object and
 179emits the new commit object id on stdout. If no parent is given then
 180it is considered to be an initial tree.
 181
 182A commit object usually has 1 parent (a commit after a change) or up
 183to 16 parents.  More than one parent represents a merge of branches
 184that led to them.
 185
 186While a tree represents a particular directory state of a working
 187directory, a commit represents that state in "time", and explains how
 188to get there.
 189
 190Normally a commit would identify a new "HEAD" state, and while git
 191doesn't care where you save the note about that state, in practice we
 192tend to just write the result to the file ".git/HEAD", so that we can
 193always see what the last committed state was.
 194
 195Options
 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
 204Commit Information
 205
 206A commit encapsulates:
 207        all parent object ids
 208        author name, email and date
 209        committer name and email and the commit time.
 210
 211If not provided, commit-tree uses your name, hostname and domain to
 212provide author and committer info. This can be overridden using the
 213following 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
 221A commit comment is read from stdin (max 999 chars). If a changelog
 222entry is not provided via '<' redirection, commit-tree will just wait
 223for one to be entered and terminated with ^D
 224
 225see also: write-tree
 226
 227
 228################################################################
 229diff-cache
 230        diff-cache [-p] [-r] [-z] [--cached] <tree/commit>
 231
 232Compares the content and mode of the blobs found via a tree object
 233with the content of the current cache and, optionally ignoring the
 234stat 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
 251Output format:
 252
 253See "Output format from diff-cache, diff-tree and show-diff" section.
 254
 255Operating Modes
 256
 257You 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
 259that don't match the stat state as being "tentatively changed".  Both
 260of these operations are very useful indeed.
 261
 262Cached Mode
 263
 264If --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
 268For example, let's say that you have worked on your index file, and are
 269ready to commit. You want to see eactly _what_ you are going to commit is
 270without having to write a new tree object and compare it that way, and to
 271do that, you just do
 272
 273        diff-cache --cached $(cat .git/HEAD)
 274
 275Example: let's say I had renamed "commit.c" to "git-commit.c", and I had 
 276done 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 
 278my 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
 283And as you can see, the output matches "diff-tree -r" output (we
 284always do equivalent of "-r", since the index is flat).
 285You can trivially see that the above is a rename.
 286
 287In fact, "diff-cache --cached" _should_ always be entirely equivalent to
 288actually doing a "write-tree" and comparing that. Except this one is much
 289nicer for the case where you just want to check where you are.
 290
 291So doing a "diff-cache --cached" is basically very useful when you are 
 292asking yourself "what have I already marked for being committed, and 
 293what's the difference to a previous tree".
 294
 295Non-cached Mode
 296
 297The "non-cached" mode takes a different approach, and is potentially
 298the even more useful of the two in that what it does can't be emulated
 299with a "write-tree + diff-tree". Thus that's the default mode.  The
 300non-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
 305which is obviously a very useful question too, since that tells you what
 306you _could_ commit. Again, the output matches the "diff-tree -r" output to
 307a tee, but with a twist.
 308
 309The twist is that if some file doesn't match the cache, we don't have a
 310backing store thing for it, and we use the magic "all-zero" sha1 to show
 311that. So let's say that you have edited "kernel/sched.c", but have not
 312actually done an update-cache on it yet - there is no "object" associated
 313with 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
 318ie it shows that the tree has changed, and that "kernel/sched.c" has is
 319not up-to-date and may contain new stuff. The all-zero sha1 means that to
 320get the real diff, you need to look at the object in the working directory
 321directly rather than do an object-to-object diff.
 322
 323NOTE! As with other commands of this type, "diff-cache" does not actually 
 324look at the contents of the file at all. So maybe "kernel/sched.c" hasn't 
 325actually changed, and it's just that you touched it. In either case, it's 
 326a note that you need to upate-cache it to make the cache be in sync.
 327
 328NOTE 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
 330which file is in which state, since the "has been updated" ones show a
 331valid sha1, and the "not in sync with the index" ones will always have the
 332special all-zero sha1.
 333
 334################################################################
 335diff-tree
 336        diff-tree [-p] [-r] [-z] <tree/commit> <tree/commit> [<pattern>]*
 337
 338Compares the content and mode of the blobs found via two tree objects.
 339
 340Note 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
 361Limiting Output
 362
 363If you're only interested in differences in a subset of files, for
 364example some architecture-specific files, you might do:
 365
 366        diff-tree -r <tree/commit> <tree/commit> arch/ia64 include/asm-ia64
 367
 368and it will only show you what changed in those two directories.
 369
 370Or 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
 374and it will ignore all differences to other files.
 375
 376The pattern is always the prefix, and is matched exactly (ie there are no
 377wildcards - although matching a directory, which it does support, can
 378obviously be seen as a "wildcard" for all the files under that directory).
 379
 380Output format:
 381
 382See "Output format from diff-cache, diff-tree and show-diff" section.
 383
 384An example of normal usage is:
 385
 386        torvalds@ppc970:~/git> diff-tree 5319e4d609cdd282069cc4dce33c1db559539b03 b4e628ea30d5ab3606119d2ea5caeab141d38df7
 387        *100664->100664 blob    ac348b7d5278e9d04e3a1cd417389379c32b014f->a01513ed4d4d565911a60981bfb4173311ba3688      fsck-cache.c
 388
 389which tells you that the last commit changed just one file (it's from
 390this 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
 403in case you care).
 404
 405################################################################
 406diff-tree-helper
 407        diff-tree-helper [-z]
 408
 409Reads output from diff-cache, diff-tree and show-diff and
 410generates patch format output.
 411
 412-z
 413        \0 line termination on input
 414
 415See also the section on generating patches.
 416
 417################################################################
 418fsck-cache
 419        fsck-cache [[--unreachable] <commit>*]
 420
 421Verifies 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
 431It tests SHA1 and general object sanity, but it does full tracking of
 432the resulting reachability and everything else. It prints out any
 433corruption it finds (missing or bad objects), and if you use the
 434"--unreachable" flag it will also print out objects that exist but
 435that aren't readable from any of the specified root nodes.
 436
 437So for example
 438
 439        fsck-cache --unreachable $(cat .git/HEAD)
 440
 441or, for Cogito users:
 442
 443        fsck-cache --unreachable $(cat .git/heads/*)
 444
 445will do quite a _lot_ of verification on the tree. There are a few
 446extra validity tests to be added (make sure that tree objects are
 447sorted properly etc), but on the whole if "fsck-cache" is happy, you
 448do have a valid tree.
 449
 450Any 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
 452the hopes that somebody else has the object you have corrupted).
 453
 454Of course, "valid tree" doesn't mean that it wasn't generated by some
 455evil person, and the end result might be crap. Git is a revision
 456tracking system, not a quality assurance system ;)
 457
 458Extracted Diagnostics
 459
 460expect 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
 465missing sha1 directory '<dir>'
 466        The directory holding the sha1 objects is missing.
 467
 468unreachable <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
 476missing <type> <object>
 477        The <type> object <object>, is referred to but isn't present in
 478        the database.
 479
 480dangling <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
 484warning: fsck-cache: tree <tree> has full pathnames in it
 485        And it shouldn't...
 486
 487sha1 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
 494Environment Variables
 495
 496SHA1_FILE_DIRECTORY
 497        used to specify the object database root (usually .git/objects)
 498
 499################################################################
 500git-export
 501        git-export top [base]
 502
 503probably deprecated:
 504On 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
 512That's fine. It was a quick hack, just to show that if somebody wants to, 
 513the data is trivially exportable.
 514
 515                Linus
 516
 517Although in Linus' distribution, git-export is not part of 'core' git.
 518
 519################################################################
 520init-db
 521        init-db
 522
 523This simply creates an empty git object database - basically a .git
 524directory.
 525
 526If the object storage directory is specified via the
 527SHA1_FILE_DIRECTORY environment variable then the sha1 directories are
 528created underneath - otherwise the default .git/objects directory is
 529used.
 530
 531init-db won't hurt an existing repository.
 532
 533
 534################################################################
 535ls-tree
 536        ls-tree [-r] [-z] <tree/commit>
 537
 538convert the tree object to a human readable (and script
 539processable) 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
 549Output Format
 550<mode>\t        <type>\t        <object>\t      <path><file>    
 551
 552
 553################################################################
 554merge-base
 555        merge-base <commit> <commit>
 556
 557merge-base finds as good a common ancestor as possible. Given a
 558selection of equally good common ancestors it should not be relied on
 559to decide in any particular way.
 560
 561The merge-base algorithm is still in flux - use the source...
 562
 563
 564################################################################
 565merge-cache
 566        merge-cache <merge-program> (-a | -- | <file>*) 
 567
 568This looks up the <file>(s) in the cache and, if there are any merge
 569entries, unpacks all of them (which may be just one file, of course)
 570into up to three separate temporary files, and then executes the
 571supplied <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
 580If merge-cache is called with multiple <file>s (or -a) then it
 581processes them in turn only stopping if merge returns a non-zero exit
 582code.
 583
 584Typically this is run with the a script calling the merge command from
 585the RCS package.
 586
 587A sample script called git-merge-one-file-script is included in the
 588ditribution.
 589
 590ALERT ALERT ALERT! The git "merge object order" is different from the
 591RCS "merge" program merge object order. In the above ordering, the
 592original 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
 595Examples:
 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
 603or 
 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
 612where the latter example shows how "merge-cache" will stop trying to
 613merge once anything has returned an error (ie "cat" returned an error
 614for 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################################################################
 619read-tree
 620        read-tree (<tree/commit> | -m <tree/commit1> [<tree/commit2> <tree/commit3>])"
 621
 622Reads the tree information given by <tree> into the directory cache,
 623but does not actually _update_ any of the files it "caches". (see:
 624checkout-cache)
 625
 626Optionally, it can merge a tree into the cache or perform a 3-way
 627merge.
 628
 629Trivial merges are done by read-tree itself.  Only conflicting paths
 630will 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
 639Merging
 640If -m is specified, read-tree performs 2 kinds of merge, a single tree
 641merge if only 1 tree is given or a 3-way merge if 3 trees are
 642provided.
 643
 644Single Tree Merge
 645If only 1 tree is specified, read-tree operates as if the user did not
 646specify "-m", except that if the original cache has an entry for a
 647given pathname; and the contents of the path matches with the tree
 648being read, the stat info from the cache is used. (In other words, the
 649cache's stat()s take precedence over the merged tree's)
 650
 651That 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
 653that really changed.
 654
 655This is used to avoid unnecessary false hits when show-diff is
 656run after read-tree.
 657
 6583-Way Merge
 659Each "index" entry has two bits worth of "stage" state. stage 0 is the
 660normal one, and is the only one you'd see in any kind of normal use.
 661
 662However, when you do "read-tree" with multiple trees, the "stage"
 663starts out at 0, but increments for each tree you read. And in
 664particular, the "-m" flag means "start at stage 1" instead.
 665
 666This means that you can do
 667
 668        read-tree -m <tree1> <tree2> <tree3>
 669
 670and 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
 674Furthermore, "read-tree" has special-case logic that says: if you see
 675a 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
 687Write-tree refuses to write a nonsensical tree, so write-tree will
 688complain about unmerged entries if it sees a single entry that is not
 689stage 0".
 690
 691Ok, this all sounds like a collection of totally nonsensical rules,
 692but it's actually exactly what you want in order to do a fast
 693merge. The different stages represent the "result tree" (stage 0, aka
 694"merged"), the original tree (stage 1, aka "orig"), and the two trees
 695you are trying to merge (stage 2 and 3 respectively).
 696
 697In fact, the way "read-tree" works, it's entirely agnostic about how
 698you assign the stages, and you could really assign them any which way,
 699and the above is just a suggested way to do it (except since
 700"write-tree" refuses to write anything but stage0 entries, it makes
 701sense to always consider stage 0 to be the "full merge" state).
 702
 703So what happens? Try it out. Select the original tree, and two trees
 704to 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
 719So 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
 731Incidentally - it also means that you don't even have to have a separate 
 732subdirectory for this. All the information literally is in the index file, 
 733which is a temporary thing anyway. There is no need to worry about what is in 
 734the working directory, since it is never shown and never used.
 735
 736see also:
 737write-tree
 738show-files
 739
 740
 741################################################################
 742rev-list <commit>
 743
 744Lists commit objects in reverse chronological order starting at the
 745given commit, taking ancestry relationship into account.  This is
 746useful to produce human-readable log output.
 747
 748
 749################################################################
 750rev-tree
 751        rev-tree [--edges] [--cache <cache-file>] [^]<commit> [[^]<commit>]
 752
 753Provides 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
 766Output:
 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        
 791A revtree can get quite large. rev-tree will eventually allow you to
 792cache previous state so that you don't have to follow the whole thing
 793down.
 794
 795So 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
 802the head revisions - the ones that aren't referred to by other
 803revisions - in "common-revision", and figure out the best one. I
 804think.)
 805
 806
 807################################################################
 808show-diff
 809        show-diff [-p] [-q] [-s] [-z] [paths...]
 810
 811Compares the files in the working tree and the cache.  When paths
 812are specified, compares only those named paths.  Otherwise all
 813entries in the cache are compared.  The output format is the
 814same 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
 825Output format:
 826
 827See "Output format from diff-cache, diff-tree and show-diff" section.
 828
 829################################################################
 830show-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
 837This merges the file listing in the directory cache index with the
 838actual working directory list, and shows different combinations of the
 839two.
 840
 841One or more of the options below may be used to determine the files
 842shown:
 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
 885Output
 886show files just outputs the filename unless --stage is specified in
 887which case it outputs:
 888
 889[<tag> ]<mode> <object> <stage> <file>
 890
 891show-files --unmerged" and "show-files --stage " can be used to examine
 892detailed information on unmerged paths.
 893
 894For an unmerged path, instead of recording a single mode/SHA1 pair,
 895the dircache records up to three such pairs; one from tree O in stage
 8961, A in stage 2, and B in stage 3.  This information can be used by
 897the user (or Cogito) to see what should eventually be recorded at the
 898path. (see read-cache for more information on state)
 899
 900see also:
 901read-cache
 902
 903
 904################################################################
 905unpack-file
 906        unpack-file <blob>
 907
 908Creates a file holding the contents of the blob specified by sha1. It
 909returns 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################################################################
 916update-cache
 917        update-cache [--add] [--remove] [--refresh [--ignore-missing]]
 918                     [--cacheinfo <mode> <object> <path>]*
 919                     [--] [<file>]*
 920
 921Modifies the index or directory cache. Each file mentioned is updated
 922into the cache and any 'unmerged' or 'needs updating' state is
 923cleared.
 924
 925The way update-cache handles files it is told about can be modified
 926using 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
 959Using --refresh
 960
 961--refresh does not calculate a new sha1 file or bring the cache
 962up-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
 964can refresh the cache for a file that hasn't been changed but where
 965the stat entry is out of date.
 966
 967For example, you'd want to do this after doing a "read-tree", to link
 968up the stat cache details with the proper files.
 969
 970Using --cacheinfo
 971--cacheinfo is used to register a file that is not in the current
 972working directory.  This is useful for minimum-checkout merging.
 973
 974To pretend you have a file with mode and sha1 at path, say:
 975
 976 $ update-cache --cacheinfo mode sha1 path
 977
 978To update and refresh only the files already checked out:
 979
 980   checkout-cache -n -f -a && update-cache --ignore-missing --refresh
 981
 982
 983################################################################
 984write-tree
 985        write-tree
 986
 987Creates a tree object using the current cache.
 988
 989The cache must be merged.
 990
 991Conceptually, write-tree sync()s the current directory cache contents
 992into a set of tree files.
 993In order to have that match what is actually in your directory right
 994now, you need to have done a "update-cache" phase before you did the
 995"write-tree".
 996
 997
 998################################################################
 999
1000Output format from diff-cache, diff-tree and show-diff.
1001
1002These commands all compare two sets of things; what are
1003compared 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
1021The following desription uses "old" and "new" to mean those
1022compared entities.
1023
1024For files in old but not in new (i.e. removed):
1025-<mode> \t <type> \t <object> \t <path>
1026
1027For files not in old but in new (i.e. added):
1028+<mode> \t <type> \t <object> \t <path>
1029
1030For 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
1034filesystem and it is out of sync with the cache.  Example:
1035
1036    *100644->100660 blob    5be4a414b32cf4204f889469942986d3d783da84->0000000000000000000000000000000000000000      file.c
1037
1038################################################################
1039
1040Generating patches
1041
1042When diff-cache, diff-tree, or show-diff are run with a -p
1043option, they do not produce the output described in "Output
1044format from diff-cache, diff-tree and show-diff" section.  It
1045instead produces a patch file.
1046
1047The patch generation can be customized at two levels.  This
1048customization also applies to diff-tree-helper.
1049
10501. 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
10742. 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
1101Terminology: - see README for description
1102Each line contains terms used interchangeably
1103
1104object database, .git directory
1105directory cache, index
1106id, sha1, sha1-id, sha1 hash
1107type, tag
1108blob, blob object
1109tree, tree object
1110commit, commit object
1111parent
1112root object
1113changeset
1114
1115
1116git Environment Variables
1117AUTHOR_NAME
1118AUTHOR_EMAIL
1119AUTHOR_DATE
1120COMMIT_AUTHOR_NAME
1121COMMIT_AUTHOR_EMAIL
1122GIT_DIFF_CMD
1123GIT_DIFF_OPTS
1124GIT_EXTERNAL_DIFF
1125GIT_INDEX_FILE
1126SHA1_FILE_DIRECTORY
1127
1128