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