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.
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!
9 Thanks to original email authors and proof readers esp Junio C Hamano
12 David Greaves <david@dgreaves.com>
15 Identifier terminology used:
18 Indicates any object sha1 identifier
21 Indicates a blob object sha1 identifier
24 Indicates a tree object sha1 identifier
27 Indicates a commit object sha1 identifier
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]
36 Indicates that an object type is required.
37 Currently one of: blob/tree/commit
40 Indicates a filename - often includes leading path
43 Indicates the path of a file (is this ever useful?)
47 ################################################################
49 cat-file (-t | <type>) <object>
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.
55 The sha1 identifier of the object.
58 show the object type identified by <object>
61 One of: blob/tree/commit
65 If -t is specified, one of:
68 Otherwise the raw (though uncompressed) contents of the <object> will
72 ################################################################
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.
79 Files that do not exist on the filesystem are considered up-to-date
80 (whether or not they are in the cache).
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
86 preparing to update file <file> not uptodate in cache
87 <file> on disk is not up-to-date with the cache
89 exits with a status code indicating success if all files are
92 see also: update-cache
95 ################################################################
97 checkout-cache [-q] [-a] [-f] [-n] [--prefix=<string>]
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.
106 be quiet if files exist or are not in the cache
109 forces overwrite of existing files
112 checks out all files in the cache (will then continue to
113 process listed files).
115 Don't checkout new files, only refresh files already checked
119 When creating files, prepend <string> (usually a directory
120 including a trailing /)
123 Do not interpret any more arguments as options.
125 Note that the order of the flags matters:
127 checkout-cache -a -f file.c
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).
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".
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
141 find . -name '*.h' -print0 | xargs -0 checkout-cache -f --
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.
147 To update and refresh only the files already checked out:
149 checkout-cache -n -f -a && update-cache --ignore-missing --refresh
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
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
160 checkout-cache --prefix=export-dir/ -a
162 and checkout-cache will "export" the cache into the specified
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
168 checkout-cache --prefix=.merged- Makefile
170 to check out the currently cached copy of "Makefile" into the file
174 ################################################################
176 commit-tree <tree> [-p <parent commit>]* < changelog
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.
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
186 While a tree represents a particular directory state of a working
187 directory, a commit represents that state in "time", and explains how
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.
198 An existing tree object
201 Each -p indicates a the id of a parent commit object.
206 A commit encapsulates:
207 all parent object ids
208 author name, email and date
209 committer name and email and the commit time.
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.
219 (nb <,> and '\n's are stripped)
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
228 ################################################################
230 diff-cache [-p] [-r] [-z] [--cached] <tree/commit>
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.
237 The id of a tree or commit object to diff against.
240 generate patch (see section on generating patches)
246 \0 line termination on output
249 do not consider the on-disk file at all
253 See "Output format from diff-cache, diff-tree and show-diff" section.
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.
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")
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
273 diff-cache --cached $(cat .git/HEAD)
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
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.
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.
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".
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
302 "show me the differences between HEAD and the currently checked out
303 tree - index contents _and_ files that aren't up-to-date"
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.
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:
315 torvalds@ppc970:~/v2.6/linux> diff-cache $(cat .git/HEAD )
316 *100644->100664 blob 7476bbcfe5ef5a1dd87d745f298b831143e4d77e->0000000000000000000000000000000000000000 kernel/sched.c
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.
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.
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.
334 ################################################################
336 diff-tree [-p] [-r] [-z] <tree/commit> <tree/commit> [<pattern>]*
338 Compares the content and mode of the blobs found via two tree objects.
340 Note that diff-tree can use the tree encapsulated in a commit object.
343 The id of a tree or commit object.
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.
353 generate patch (see section on generating patches)
359 \0 line termination on output
363 If you're only interested in differences in a subset of files, for
364 example some architecture-specific files, you might do:
366 diff-tree -r <tree/commit> <tree/commit> arch/ia64 include/asm-ia64
368 and it will only show you what changed in those two directories.
370 Or if you are searching for what changed in just kernel/sched.c, just do
372 diff-tree -r <tree/commit> <tree/commit> kernel/sched.c
374 and it will ignore all differences to other files.
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).
382 See "Output format from diff-cache, diff-tree and show-diff" section.
384 An example of normal usage is:
386 torvalds@ppc970:~/git> diff-tree 5319e4d609cdd282069cc4dce33c1db559539b03 b4e628ea30d5ab3606119d2ea5caeab141d38df7
387 *100664->100664 blob ac348b7d5278e9d04e3a1cd417389379c32b014f->a01513ed4d4d565911a60981bfb4173311ba3688 fsck-cache.c
389 which tells you that the last commit changed just one file (it's from
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
398 Make "fsck-cache" print out all the root commits it finds.
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.
405 ################################################################
407 diff-tree-helper [-z]
409 Reads output from diff-cache, diff-tree and show-diff and
410 generates patch format output.
413 \0 line termination on input
415 See also the section on generating patches.
417 ################################################################
419 fsck-cache [[--unreachable] <commit>*]
421 Verifies the connectivity and validity of the objects in the database.
424 A commit object to treat as the head of an unreachability
428 print out objects that exist but that aren't readable from any
429 of the specified root nodes
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.
439 fsck-cache --unreachable $(cat .git/HEAD)
441 or, for Cogito users:
443 fsck-cache --unreachable $(cat .git/heads/*)
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.
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).
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 ;)
458 Extracted Diagnostics
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
465 missing sha1 directory '<dir>'
466 The directory holding the sha1 objects is missing.
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
476 missing <type> <object>
477 The <type> object <object>, is referred to but isn't present in
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.
484 warning: fsck-cache: tree <tree> has full pathnames in it
487 sha1 mismatch <object>
488 The database has an object who's sha1 doesn't match the
490 This indicates a ??serious?? data integrity problem.
491 (note: this error occured during early git development when
492 the database format changed.)
494 Environment Variables
497 used to specify the object database root (usually .git/objects)
499 ################################################################
501 git-export top [base]
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.
512 That's fine. It was a quick hack, just to show that if somebody wants to,
513 the data is trivially exportable.
517 Although in Linus' distribution, git-export is not part of 'core' git.
519 ################################################################
523 This simply creates an empty git object database - basically a .git
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
531 init-db won't hurt an existing repository.
534 ################################################################
536 ls-tree [-r] [-z] <tree/commit>
538 convert the tree object to a human readable (and script
542 Id of a tree or commit object.
544 recurse into sub-trees
547 \0 line termination on output
550 <mode>\t <type>\t <object>\t <path><file>
553 ################################################################
555 merge-base <commit> <commit>
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.
561 The merge-base algorithm is still in flux - use the source...
564 ################################################################
566 merge-cache <merge-program> (-a | -- | <file>*)
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.
575 Interpret all future arguments as filenames
578 Run merge against all files in the cache that need merging.
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
584 Typically this is run with the a script calling the merge command from
587 A sample script called git-merge-one-file-script is included in the
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.
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
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
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).
618 ################################################################
620 read-tree (<tree/commit> | -m <tree/commit1> [<tree/commit2> <tree/commit3>])"
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:
626 Optionally, it can merge a tree into the cache or perform a 3-way
629 Trivial merges are done by read-tree itself. Only conflicting paths
630 will be in unmerged state when read-tree returns.
633 Perform a merge, not just a read
636 The id of the tree object(s) to be read/merged.
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
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)
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
655 This is used to avoid unnecessary false hits when show-diff is
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.
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.
666 This means that you can do
668 read-tree -m <tree1> <tree2> <tree3>
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".
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":
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)
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)
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)
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
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).
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).
703 So what happens? Try it out. Select the original tree, and two trees
704 to merge, and look how it works:
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.
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.
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.
719 So now the merge algorithm ends up being really simple:
721 - you walk the index in order, and ignore all entries of stage 0,
722 since they've already been done.
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 ..
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.
741 ################################################################
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.
749 ################################################################
751 rev-tree [--edges] [--cache <cache-file>] [^]<commit> [[^]<commit>]
753 Provides the revision tree for one or more commits.
756 Show edges (ie places where the marking changes between parent
760 Use the specified file as a cache. [Not implemented yet]
763 The commit id to trace (a leading caret means to ignore this
767 <date> <commit>:<flags> [<parent-commit>:<flags> ]*
770 Date in 'seconds since epoch'
776 id of each parent commit object (>1 indicates a merge)
780 The flags are read as a bitmask representing each commit
781 provided on the commandline. eg: given the command:
783 $ rev-tree <com1> <com2> <com3>
789 means that <commit> is reachable from <com1>(1) and <com3>(4)
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
795 So the change difference between two commits is literally
797 rev-tree [commit-id1] > commit1-revtree
798 rev-tree [commit-id2] > commit2-revtree
799 join -t : commit1-revtree commit2-revtree > common-revisions
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
807 ################################################################
809 show-diff [-p] [-q] [-s] [-z] [paths...]
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.
817 generate patch (see section on generating patches)
820 Remain silent even on nonexisting files
823 Does not do anything other than what -q does.
827 See "Output format from diff-cache, diff-tree and show-diff" section.
829 ################################################################
832 (--[cached|deleted|others|ignored|stage|unmerged])*
834 [-x <pattern>|--exclude=<pattern>]
835 [-X <file>|--exclude-from=<file>]
837 This merges the file listing in the directory cache index with the
838 actual working directory list, and shows different combinations of the
841 One or more of the options below may be used to determine the files
845 Show cached files in the output (default)
848 Show deleted files in the output
851 Show other files in the output
854 Show ignored files in the output
855 Note the this also reverses any exclude list present.
858 Show stage files in the output
861 Show unmerged files in the output (forces --stage)
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:
872 \0 line termination on output
874 -x|--exclude=<pattern>
875 Skips files matching pattern.
876 Note that pattern is a shell wildcard pattern.
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
883 show-files --others --exclude-from=dontdiff
886 show files just outputs the filename unless --stage is specified in
887 which case it outputs:
889 [<tag> ]<mode> <object> <stage> <file>
891 show-files --unmerged" and "show-files --stage " can be used to examine
892 detailed information on unmerged paths.
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)
904 ################################################################
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:
915 ################################################################
917 update-cache [--add] [--remove] [--refresh [--ignore-missing]]
918 [--cacheinfo <mode> <object> <path>]*
921 Modifies the index or directory cache. Each file mentioned is updated
922 into the cache and any 'unmerged' or 'needs updating' state is
925 The way update-cache handles files it is told about can be modified
926 using the various options:
929 If a specified file isn't in the cache already then it's
931 Default behaviour is to ignore new files.
934 If a specified file is in the cache but is missing then it's
936 Default behaviour is to ignore removed file.
939 Looks at the current cache and checks to see if merges or
940 updates are needed by checking stat() information.
943 Ignores missing files during a --refresh
945 --cacheinfo <mode> <object> <path>
946 Directly insert the specified info into the cache.
949 Do not interpret any more arguments as options.
953 Note that files begining with '.' are discarded. This includes
954 "./file" and "dir/./file". If you don't want this, then use
956 The same applies to directories ending '/' and paths with '//'
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.
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.
971 --cacheinfo is used to register a file that is not in the current
972 working directory. This is useful for minimum-checkout merging.
974 To pretend you have a file with mode and sha1 at path, say:
976 $ update-cache --cacheinfo mode sha1 path
978 To update and refresh only the files already checked out:
980 checkout-cache -n -f -a && update-cache --ignore-missing --refresh
983 ################################################################
987 Creates a tree object using the current cache.
989 The cache must be merged.
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
998 ################################################################
1000 Output format from diff-cache, diff-tree and show-diff.
1002 These commands all compare two sets of things; what are
1003 compared are different:
1005 diff-cache <tree/commit>
1007 compares the <tree/commit> and the files on the filesystem.
1009 diff-cache --cached <tree/commit>
1011 compares the <tree/commit> and the cache.
1013 diff-tree [-r] <tree/commit-1> <tree/commit-2> [paths...]
1015 compares the trees named by the two arguments.
1017 show-diff [paths...]
1019 compares the cache and the files on the filesystem.
1021 The following desription uses "old" and "new" to mean those
1024 For files in old but not in new (i.e. removed):
1025 -<mode> \t <type> \t <object> \t <path>
1027 For files not in old but in new (i.e. added):
1028 +<mode> \t <type> \t <object> \t <path>
1030 For files that differ:
1031 *<old-mode>-><new-mode> \t <type> \t <old-sha1>-><new-sha1> \t <path>
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:
1036 *100644->100660 blob 5be4a414b32cf4204f889469942986d3d783da84->0000000000000000000000000000000000000000 file.c
1038 ################################################################
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.
1047 The patch generation can be customized at two levels. This
1048 customization also applies to diff-tree-helper.
1050 1. When the environment variable GIT_EXTERNAL_DIFF is not set,
1051 these commands internally invoke diff like this:
1053 diff -L k/<path> -L l/<path> -pu <old> <new>
1055 For added files, /dev/null is used for <old>. For removed
1056 files, /dev/null is used for <new>
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
1063 GIT_DIFF_CMD="diff -L'%s' -L'%s'" show-diff -p
1065 Caution: Do not use more than two '%s' in GIT_DIFF_CMD.
1067 The diff formatting options can be customized via the
1068 environment variable GIT_DIFF_OPTS. For example, if you
1069 prefer context diff:
1071 GIT_DIFF_OPTS=-c diff-cache -p $(cat .git/HEAD)
1074 2. When the environment variable GIT_EXTERNAL_DIFF is set, the
1075 program named by it is called, instead of the diff invocation
1078 For a path that is added, removed, or modified,
1079 GIT_EXTERNAL_DIFF is called with 7 parameters:
1081 path old-file old-hex old-mode new-file new-hex new-mode
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.
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.
1096 For a path that is unmerged, GIT_EXTERNAL_DIFF is called with
1099 ################################################################
1101 Terminology: - see README for description
1102 Each line contains terms used interchangeably
1104 object database, .git directory
1105 directory cache, index
1106 id, sha1, sha1-id, sha1 hash
1110 commit, commit object
1116 git Environment Variables