{"thread":{"id":"592","subject":"[PATCH] update README and #include in git.txt","startedAt":"2005-05-12T21:31:05Z","lastAt":"2005-05-13T22:57:57Z","messageCount":4,"participants":["David Greaves","Petr Baudis"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3205","messageId":"4283CB19.3050208@dgreaves.com","threadId":"592","inReplyTo":null,"subject":"[PATCH] update README and #include in git.txt","fromName":"David Greaves","fromEmail":"david@dgreaves.com","sentAt":"2005-05-12T21:31:05Z","receivedAt":"2005-05-12T21:31:05Z","isPatch":true,"sender":{"key":"david@dgreaves.com","avatar":"https://gravatar.com/avatar/ca67bad50999edcdd137c9a65da2381557d175bea99ae956afdabc5785e42b79?d=mp&s=160"},"body":"Hi Petr\nI sent this to Junio just as he was shutting down his tree.\nCan you take it into yours?\n(This is the README from Linus' tree)\n\nDavid\n\n\nMakefile understands the includes git.txt #includes README\nREADME reformatted to asciidoc to allow inclusion in git.txt\n\nSigned-off-by: David Greaves <david@dgreaves.com>\n\n---\ncommit 14d464865c5e204793c2244bdc4aba0ecd6d593d\ntree e0e578bb02a7d8db1c105fddf5b5168ad0c79088\nparent d81ed1b591b1db413c91e29b66de6a14dc543ffc\nauthor David Greaves <david@dgreaves.com> Wed, 11 May 2005 16:20:23 +0100\ncommitter David Greaves <david@dgreaves.com> Wed, 11 May 2005 16:20:23 +0100\n\n Documentation/Makefile |    8\n Documentation/git.txt  |   19 -\n README                 |  728 +++++++++++++++++++++++++------------------------\n 3 files changed, 390 insertions(+), 365 deletions(-)\n\nIndex: Documentation/Makefile\n===================================================================\n--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/Documentation/Makefile  (mode:100644)\n+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/Documentation/Makefile  (mode:100644)\n@@ -8,8 +8,12 @@\n\n man: $(DOC_MAN)\n\n-git-%: %.c $(LIB_FILE)\n-\t$(CC) $(CFLAGS) -o $@ $(filter %.c,$^) $(LIBS)\n+# 'include' dependencies\n+git.txt: ../README\n+\ttouch git.txt\n+\n+git-diff-*.txt: diff-format.txt\n+\ttouch $@\n\n clean:\n \trm -f *.xml *.html *.1\nIndex: Documentation/git.txt\n===================================================================\n--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/Documentation/git.txt  (mode:100644)\n+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/Documentation/git.txt  (mode:100644)\n@@ -16,9 +16,10 @@\n\n This is reference information for the core git commands.\n\n-The link:README[] contains much useful definition and clarification\n-info - read that first.  And of the commands, I suggest reading\n-'git-update-cache' and 'git-read-tree' first - I wish I had!\n+The Discussion section below contains much useful definition and\n+clarification info - read that first.  And of the commands, I suggest\n+reading link:git-update-cache.html[git-update-cache] and\n+link:git-read-tree.html[git-read-tree] first - I wish I had!\n\n David Greaves <david@dgreaves.com>\n 08/05/05\n@@ -230,18 +231,12 @@\n\n Terminology\n -----------\n-Each line contains terms used interchangeably\n+Each line contains terms which you may see used interchangeably\n\n  object database, .git directory\n  directory cache, index\n  id, sha1, sha1-id, sha1 hash\n  type, tag\n- blob, blob object\n- tree, tree object\n- commit, commit object\n- parent\n- root object\n- changeset\n\n\n Environment Variables\n@@ -295,6 +290,10 @@\n \tlink:git-diff-files.html[git-diff-files];\n \tlink:git-diff-tree.html[git-diff-tree]\n\n+Discussion\n+----------\n+include::../README[]\n+\n Author\n ------\n Written by Linus Torvalds <torvalds@osdl.org>\nIndex: README\n===================================================================\n--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/README  (mode:100644)\n+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/README  (mode:100644)\n@@ -1,9 +1,13 @@\n+////////////////////////////////////////////////////////////////\n+\tGIT - the stupid content tracker\n\n\n-\n-\tGIT - the stupid content tracker\n+Note that this README is written in asciidoc format and is #include'd\n+in the git.txt docs\n\n\n+The rest of this README is #included in the git.txt file\n+////////////////////////////////////////////////////////////////\n \"git\" can mean anything, depending on your mood.\n\n  - random three-letter combination that is pronounceable, and not\n@@ -23,21 +27,19 @@\n \"current directory cache\" aka \"index\".\n\n\n-\n-\tThe Object Database (GIT_OBJECT_DIRECTORY)\n-\n-\n+The Object Database\n+~~~~~~~~~~~~~~~~~~~\n The object database is literally just a content-addressable collection\n of objects.  All objects are named by their content, which is\n approximated by the SHA1 hash of the object itself.  Objects may refer\n-to other objects (by referencing their SHA1 hash), and so you can build\n-up a hierarchy of objects.\n+to other objects (by referencing their SHA1 hash), and so you can\n+build up a hierarchy of objects.\n\n All objects have a statically determined \"type\" aka \"tag\", which is\n determined at object creation time, and which identifies the format of\n-the object (i.e. how it is used, and how it can refer to other objects).\n-There are currently three different object types: \"blob\", \"tree\" and\n-\"commit\".\n+the object (ie how it is used, and how it can refer to other objects).\n+There are currently four different object types: \"blob\", \"tree\",\n+\"commit\" and \"tag\".\n\n A \"blob\" object cannot refer to any other object, and is, like the tag\n implies, a pure storage object containing some user data.  It is used to\n@@ -48,7 +50,7 @@\n directory structure. In addition, a tree object can refer to other tree\n objects, thus creating a directory hierarchy.\n\n-Finally, a \"commit\" object ties such directory hierarchies together into\n+A \"commit\" object ties such directory hierarchies together into\n a DAG of revisions - each \"commit\" is associated with exactly one tree\n (the directory hierarchy at the time of the commit). In addition, a\n \"commit\" refers to one or more \"parent\" commit objects that describe the\n@@ -62,12 +64,17 @@\n just going to confuse people.  So aim for the notion of \"one root object\n per project\", even if git itself does not enforce that.\n\n+A \"tag\" object symbolically identifies and can be used to sign other\n+objects. It contains the identifier and type of another object, a\n+symbolic name (of course!) and, optionally, a signature.\n+\n Regardless of object type, all objects are share the following\n characteristics: they are all in deflated with zlib, and have a header\n that not only specifies their tag, but also size information about the\n data in the object.  It's worth noting that the SHA1 hash that is used\n-to name the object is always the hash of this _compressed_ object, not\n-the original data.\n+to name the object is the hash of the original data (historical note:\n+in the dawn of the age of git this was the sha1 of the _compressed_\n+object)\n\n As a result, the general consistency of an object can always be tested\n independently of the contents or the type of the object: all objects can\n@@ -76,157 +83,179 @@\n forms a sequence of <ascii tag without space> + <space> + <ascii decimal\n size> + <byte\\0> + <binary object data>.\n\n-The structured objects can further have their structure and connectivity\n-to other objects verified. This is generally done with the \"fsck-cache\"\n-program, which generates a full dependency graph of all objects, and\n-verifies their internal consistency (in addition to just verifying their\n-superficial consistency through the hash).\n+The structured objects can further have their structure and\n+connectivity to other objects verified. This is generally done with\n+the \"git-fsck-cache\" program, which generates a full dependency graph\n+of all objects, and verifies their internal consistency (in addition\n+to just verifying their superficial consistency through the hash).\n\n The object types in some more detail:\n\n-  BLOB: A \"blob\" object is nothing but a binary blob of data, and\n-\tdoesn't refer to anything else.  There is no signature or any\n-\tother verification of the data, so while the object is\n-\tconsistent (it _is_ indexed by its sha1 hash, so the data itself\n-\tis certainly correct), it has absolutely no other attributes.\n-\tNo name associations, no permissions.  It is purely a blob of\n-\tdata (i.e. normally \"file contents\").\n-\n-\tIn particular, since the blob is entirely defined by its data,\n-\tif two files in a directory tree (or in multiple different\n-\tversions of the repository) have the same contents, they will\n-\tshare the same blob object. The object is totally independent\n-\tof it's location in the directory tree, and renaming a file does\n-\tnot change the object that file is associated with in any way.\n-\n-  TREE: The next hierarchical object type is the \"tree\" object.  A tree\n-\tobject is a list of mode/name/blob data, sorted by name.\n-\tAlternatively, the mode data may specify a directory mode, in\n-\twhich case instead of naming a blob, that name is associated\n-\twith another TREE object.\n-\n-\tLike the \"blob\" object, a tree object is uniquely determined by\n-\tthe set contents, and so two separate but identical trees will\n-\talways share the exact same object. This is true at all levels,\n-\ti.e. it's true for a \"leaf\" tree (which does not refer to any\n-\tother trees, only blobs) as well as for a whole subdirectory.\n-\n-\tFor that reason a \"tree\" object is just a pure data abstraction:\n-\tit has no history, no signatures, no verification of validity,\n-\texcept that since the contents are again protected by the hash\n-\titself, we can trust that the tree is immutable and its contents\n-\tnever change.\n-\n-\tSo you can trust the contents of a tree to be valid, the same\n-\tway you can trust the contents of a blob, but you don't know\n-\twhere those contents _came_ from.\n-\n-\tSide note on trees: since a \"tree\" object is a sorted list of\n-\t\"filename+content\", you can create a diff between two trees\n-\twithout actually having to unpack two trees.  Just ignore all\n-\tcommon parts, and your diff will look right.  In other words,\n-\tyou can effectively (and efficiently) tell the difference\n-\tbetween any two random trees by O(n) where \"n\" is the size of\n-\tthe difference, rather than the size of the tree.\n-\n-\tSide note 2 on trees: since the name of a \"blob\" depends\n-\tentirely and exclusively on its contents (i.e. there are no names\n-\tor permissions involved), you can see trivial renames or\n-\tpermission changes by noticing that the blob stayed the same.\n-\tHowever, renames with data changes need a smarter \"diff\" implementation.\n-\n-CHANGESET: The \"changeset\" object is an object that introduces the\n-\tnotion of history into the picture.  In contrast to the other\n-\tobjects, it doesn't just describe the physical state of a tree,\n-\tit describes how we got there, and why.\n-\n-\tA \"changeset\" is defined by the tree-object that it results in,\n-\tthe parent changesets (zero, one or more) that led up to that\n-\tpoint, and a comment on what happened.  Again, a changeset is\n-\tnot trusted per se: the contents are well-defined and \"safe\" due\n-\tto the cryptographically strong signatures at all levels, but\n-\tthere is no reason to believe that the tree is \"good\" or that\n-\tthe merge information makes sense.  The parents do not have to\n-\tactually have any relationship with the result, for example.\n-\n-\tNote on changesets: unlike real SCM's, changesets do not contain\n-\trename information or file mode change information.  All of that\n-\tis implicit in the trees involved (the result tree, and the\n-\tresult trees of the parents), and describing that makes no sense\n-\tin this idiotic file manager.\n-\n-TRUST: The notion of \"trust\" is really outside the scope of \"git\", but\n-\tit's worth noting a few things.  First off, since everything is\n-\thashed with SHA1, you _can_ trust that an object is intact and\n-\thas not been messed with by external sources.  So the name of an\n-\tobject uniquely identifies a known state - just not a state that\n-\tyou may want to trust.\n-\n-\tFurthermore, since the SHA1 signature of a changeset refers to\n-\tthe SHA1 signatures of the tree it is associated with and the\n-\tsignatures of the parent, a single named changeset specifies\n-\tuniquely a whole set of history, with full contents.  You can't\n-\tlater fake any step of the way once you have the name of a\n-\tchangeset.\n-\n-\tSo to introduce some real trust in the system, the only thing\n-\tyou need to do is to digitally sign just _one_ special note,\n-\twhich includes the name of a top-level changeset.  Your digital\n-\tsignature shows others that you trust that changeset, and the\n-\timmutability of the history of changesets tells others that they\n-\tcan trust the whole history.\n-\n-\tIn other words, you can easily validate a whole archive by just\n-\tsending out a single email that tells the people the name (SHA1\n-\thash) of the top changeset, and digitally sign that email using\n-\tsomething like GPG/PGP.\n-\n-\tIn particular, you can also have a separate archive of \"trust\n-\tpoints\" or tags, which document your (and other peoples) trust.\n-\tYou may, of course, archive these \"certificates of trust\" using\n-\t\"git\" itself, but it's not something \"git\" does for you.\n-\n-Another way of saying the last point: \"git\" itself only handles content\n-integrity, the trust has to come from outside.\n-\n-\n-\n-\tThe \"index\" aka \"Current Directory Cache\" (\".git/index\")\n+Blob Object\n+~~~~~~~~~~~\n+A \"blob\" object is nothing but a binary blob of data, and doesn't\n+refer to anything else.  There is no signature or any other\n+verification of the data, so while the object is consistent (it _is_\n+indexed by its sha1 hash, so the data itself is certainly correct), it\n+has absolutely no other attributes.  No name associations, no\n+permissions.  It is purely a blob of data (ie normally \"file\n+contents\").\n+\n+In particular, since the blob is entirely defined by its data, if two\n+files in a directory tree (or in multiple different versions of the\n+repository) have the same contents, they will share the same blob\n+object. The object is toally independent of it's location in the\n+directory tree, and renaming a file does not change the object that\n+file is associated with in any way.\n+\n+A blob is created with link:git-write-blob.html[git-write-blob] and\n+it's data can be accessed by link:git-cat-file.html[git-cat-file]\n+\n+Tree Object\n+~~~~~~~~~~~\n+The next hierarchical object type is the \"tree\" object.  A tree object\n+is a list of mode/name/blob data, sorted by name.  Alternatively, the\n+mode data may specify a directory mode, in which case instead of\n+naming a blob, that name is associated with another TREE object.\n+\n+Like the \"blob\" object, a tree object is uniquely determined by the\n+set contents, and so two separate but identical trees will always\n+share the exact same object. This is true at all levels, ie it's true\n+for a \"leaf\" tree (which does not refer to any other trees, only\n+blobs) as well as for a whole subdirectory.\n+\n+For that reason a \"tree\" object is just a pure data abstraction: it\n+has no history, no signatures, no verification of validity, except\n+that since the contents are again protected by the hash itself, we can\n+trust that the tree is immutable and its contents never change.\n+\n+So you can trust the contents of a tree to be valid, the same way you\n+can trust the contents of a blob, but you don't know where those\n+contents _came_ from.\n+\n+Side note on trees: since a \"tree\" object is a sorted list of\n+\"filename+content\", you can create a diff between two trees without\n+actually having to unpack two trees.  Just ignore all common parts,\n+and your diff will look right.  In other words, you can effectively\n+(and efficiently) tell the difference between any two random trees by\n+O(n) where \"n\" is the size of the difference, rather than the size of\n+the tree.\n+\n+Side note 2 on trees: since the name of a \"blob\" depends entirely and\n+exclusively on its contents (ie there are no names or permissions\n+involved), you can see trivial renames or permission changes by\n+noticing that the blob stayed the same.  However, renames with data\n+changes need a smarter \"diff\" implementation.\n+\n+A tree is created with link:git-write-tree.html[git-write-tree] and\n+it's data can be accessed by link:git-ls-tree.html[git-ls-tree]\n+\n+Commit Object\n+~~~~~~~~~~~~~\n+The \"commit\" object is an object that introduces the notion of\n+history into the picture.  In contrast to the other objects, it\n+doesn't just describe the physical state of a tree, it describes how\n+we got there, and why.\n+\n+A \"commit\" is defined by the tree-object that it results in, the\n+parent commits (zero, one or more) that led up to that point, and a\n+comment on what happened.  Again, a commit is not trusted per se:\n+the contents are well-defined and \"safe\" due to the cryptographically\n+strong signatures at all levels, but there is no reason to believe\n+that the tree is \"good\" or that the merge information makes sense.\n+The parents do not have to actually have any relationship with the\n+result, for example.\n+\n+Note on commits: unlike real SCM's, commits do not contain\n+rename information or file mode chane information.  All of that is\n+implicit in the trees involved (the result tree, and the result trees\n+of the parents), and describing that makes no sense in this idiotic\n+file manager.\n+\n+A commit is created with link:git-commit-tree.html[git-commit-tree] and\n+it's data can be accessed by link:git-cat-file.html[git-cat-file]\n+\n+Trust\n+~~~~~\n+An aside on the notion of \"trust\". Trust is really outside the scope\n+of \"git\", but it's worth noting a few things.  First off, since\n+everything is hashed with SHA1, you _can_ trust that an object is\n+intact and has not been messed with by external sources.  So the name\n+of an object uniquely identifies a known state - just not a state that\n+you may want to trust.\n+\n+Furthermore, since the SHA1 signature of a commit refers to the\n+SHA1 signatures of the tree it is associated with and the signatures\n+of the parent, a single named commit specifies uniquely a whole set\n+of history, with full contents.  You can't later fake any step of the\n+way once you have the name of a commit.\n+\n+So to introduce some real trust in the system, the only thing you need\n+to do is to digitally sign just _one_ special note, which includes the\n+name of a top-level commit.  Your digital signature shows others\n+that you trust that commit, and the immutability of the history of\n+commits tells others that they can trust the whole history.\n+\n+In other words, you can easily validate a whole archive by just\n+sending out a single email that tells the people the name (SHA1 hash)\n+of the top commit, and digitally sign that email using something\n+like GPG/PGP.\n+\n+To assist in this, git also provides the tag object...\n+\n+Tag Object\n+~~~~~~~~~~\n+Git provides the \"tag\" object to simplify creating, managing and\n+exchanging symbolic and signed tokens.  The \"tag\" object at its\n+simplest simply symbolically identifies another object by containing\n+the sha1, type and symbolic name.\n+\n+However it can optionally contain additional signature information\n+(which git doesn't care about as long as there's less than 8k of\n+it). This can then be verified externally to git.\n+\n+Note that despite the tag features, \"git\" itself only handles content\n+integrity; the trust framework (and signature provision and\n+verification) has to come from outside.\n\n+A tag is created with link:git-mktag.html[git-mktag] and\n+it's data can be accessed by link:git-cat-file.html[git-cat-file]\n\n+The \"index\" aka \"Current Directory Cache\"\n+-----------------------------------------\n The index is a simple binary file, which contains an efficient\n representation of a virtual directory content at some random time.  It\n does so by a simple array that associates a set of names, dates,\n permissions and content (aka \"blob\") objects together.  The cache is\n always kept ordered by name, and names are unique (with a few very\n specific rules) at any point in time, but the cache has no long-term\n-meaning, and can be partially updated at any time.\n+meaning, and can be partially updated at any time.\n\n In particular, the index certainly does not need to be consistent with\n the current directory contents (in fact, most operations will depend on\n different ways to make the index _not_ be consistent with the directory\n hierarchy), but it has three very important attributes:\n\n- (a) it can re-generate the full state it caches (not just the directory\n-     structure: it contains pointers to the \"blob\" objects so that it\n-     can regenerate the data too)\n-\n-     As a special case, there is a clear and unambiguous one-way mapping\n-     from a current directory cache to a \"tree object\", which can be\n-     efficiently created from just the current directory cache without\n-     actually looking at any other data.  So a directory cache at any\n-     one time uniquely specifies one and only one \"tree\" object (but\n-     has additional data to make it easy to match up that tree object\n-     with what has happened in the directory)\n-\n- (b) it has efficient methods for finding inconsistencies between that\n-     cached state (\"tree object waiting to be instantiated\") and the\n-     current state.\n-\n- (c) it can additionally efficiently represent information about merge\n-     conflicts between different tree objects, allowing each pathname to\n-     be associated with sufficient information about the trees involved\n-     that you can create a three-way merge between them.\n+'(a) it can re-generate the full state it caches (not just the\n+directory structure: it contains pointers to the \"blob\" objects so\n+that it can regenerate the data too)'\n+\n+As a special case, there is a clear and unambiguous one-way mapping\n+from a current directory cache to a \"tree object\", which can be\n+efficiently created from just the current directory cache without\n+actually looking at any other data.  So a directory cache at any one\n+time uniquely specifies one and only one \"tree\" object (but has\n+additional data to make it easy to match up that tree object with what\n+has happened in the directory)\n+\n+'(b) it has efficient methods for finding inconsistencies between that\n+cached state (\"tree object waiting to be instantiated\") and the\n+current state.'\n+\n+'(c) it can additionally efficiently represent information about merge\n+conflicts between different tree objects, allowing each pathname to be\n+associated with sufficient information about the trees involved that\n+you can create a three-way merge between them.'\n\n Those are the three ONLY things that the directory cache does.  It's a\n cache, and the normal operation is to re-generate it completely from a\n@@ -245,216 +274,209 @@\n\n\n\n-\tThe Workflow\n-\n-\n+The Workflow\n+------------\n Generally, all \"git\" operations work on the index file. Some operations\n-work _purely_ on the index file (showing the current state of the\n+work *purely* on the index file (showing the current state of the\n index), but most operations move data to and from the index file. Either\n from the database or from the working directory. Thus there are four\n main combinations:\n\n- 1) working directory -> index\n-\n-\tYou update the index with information from the working directory\n-\twith the \"update-cache\" command.  You generally update the index\n-\tinformation by just specifying the filename you want to update,\n-\tlike so:\n-\n-\t\tupdate-cache filename\n-\n-\tbut to avoid common mistakes with filename globbing etc, the\n-\tcommand will not normally add totally new entries or remove old\n-\tentries, i.e. it will normally just update existing cache entries.\n-\n-\tTo tell git that yes, you really do realize that certain files\n-\tno longer exist in the archive, or that new files should be\n-\tadded, you should use the \"--remove\" and \"--add\" flags\n-\trespectively.\n-\n-\tNOTE! A \"--remove\" flag does _not_ mean that subsequent\n-\tfilenames will necessarily be removed: if the files still exist\n-\tin your directory structure, the index will be updated with\n-\ttheir new status, not removed. The only thing \"--remove\" means\n-\tis that update-cache will be considering a removed file to be a\n-\tvalid thing, and if the file really does not exist any more, it\n-\twill update the index accordingly.\n-\n-\tAs a special case, you can also do \"update-cache --refresh\",\n-\twhich will refresh the \"stat\" information of each index to match\n-\tthe current stat information. It will _not_ update the object\n-\tstatus itself, and it will only update the fields that are used\n-\tto quickly test whether an object still matches its old backing\n-\tstore object.\n-\n- 2) index -> object database\n-\n-\tYou write your current index file to a \"tree\" object with the\n-\tprogram\n-\n-\t\twrite-tree\n-\n-\tthat doesn't come with any options - it will just write out the\n-\tcurrent index into the set of tree objects that describe that\n-\tstate, and it will return the name of the resulting top-level\n-\ttree. You can use that tree to re-generate the index at any time\n-\tby going in the other direction:\n-\n- 3) object database -> index\n-\n-\tYou read a \"tree\" file from the object database, and use that to\n-\tpopulate (and overwrite - don't do this if your index contains\n-\tany unsaved state that you might want to restore later!) your\n-\tcurrent index.  Normal operation is just\n-\n-\t\tread-tree <sha1 of tree>\n-\n-\tand your index file will now be equivalent to the tree that you\n-\tsaved earlier. However, that is only your _index_ file: your\n-\tworking directory contents have not been modified.\n-\n- 4) index -> working directory\n-\n-\tYou update your working directory from the index by \"checking\n-\tout\" files. This is not a very common operation, since normally\n-\tyou'd just keep your files updated, and rather than write to\n-\tyour working directory, you'd tell the index files about the\n-\tchanges in your working directory (i.e. \"update-cache\").\n-\n-\tHowever, if you decide to jump to a new version, or check out\n-\tsomebody else's version, or just restore a previous tree, you'd\n-\tpopulate your index file with read-tree, and then you need to\n-\tcheck out the result with\n-\n-\t\tcheckout-cache filename\n-\n-\tor, if you want to check out all of the index, use \"-a\".\n-\n-\tNOTE! checkout-cache normally refuses to overwrite old files, so\n-\tif you have an old version of the tree already checked out, you\n-\twill need to use the \"-f\" flag (_before_ the \"-a\" flag or the\n-\tfilename) to _force_ the checkout.\n-\n-\n-Finally, there are a few odds and ends which are not purely moving from\n-one representation to the other:\n-\n- 5) Tying it all together\n-\n-\tTo commit a tree you have instantiated with \"write-tree\", you'd\n-\tcreate a \"commit\" object that refers to that tree and the\n-\thistory behind it - most notably the \"parent\" commits that\n-\tpreceded it in history.\n-\n-\tNormally a \"commit\" has one parent: the previous state of the\n-\ttree before a certain change was made. However, sometimes it can\n-\thave two or more parent commits, in which case we call it a\n-\t\"merge\", due to the fact that such a commit brings together\n-\t(\"merges\") two or more previous states represented by other\n-\tcommits.\n-\n-\tIn other words, while a \"tree\" represents a particular directory\n-\tstate of a working directory, a \"commit\" represents that state\n-\tin \"time\", and explains how we got there.\n-\n-\tYou create a commit object by giving it the tree that describes\n-\tthe state at the time of the commit, and a list of parents:\n-\n-\t\tcommit-tree <tree> -p <parent> [-p <parent2> ..]\n-\n-\tand then giving the reason for the commit on stdin (either\n-\tthrough redirection from a pipe or file, or by just typing it at\n-\tthe tty).\n-\n-\tcommit-tree will return the name of the object that represents\n-\tthat commit, and you should save it away for later use.\n-\tNormally, you'd commit a new \"HEAD\" state, and while git doesn't\n-\tcare where you save the note about that state, in practice we\n-\ttend to just write the result to the file \".git/HEAD\", so that\n-\twe can always see what the last committed state was.\n-\n- 6) Examining the data\n-\n-\tYou can examine the data represented in the object database and\n-\tthe index with various helper tools. For every object, you can\n-\tuse \"cat-file\" to examine details about the object:\n-\n-\t\tcat-file -t <objectname>\n-\n-\tshows the type of the object, and once you have the type (which\n-\tis usually implicit in where you find the object), you can use\n-\n-\t\tcat-file blob|tree|commit <objectname>\n-\n-\tto show its contents. NOTE! Trees have binary content, and as a\n-\tresult there is a special helper for showing that content,\n-\tcalled \"ls-tree\", which turns the binary content into a more\n-\teasily readable form.\n-\n-\tIt's especially instructive to look at \"commit\" objects, since\n-\tthose tend to be small and fairly self-explanatory. In\n-\tparticular, if you follow the convention of having the top\n-\tcommit name in \".git/HEAD\", you can do\n-\n-\t\tcat-file commit $(cat .git/HEAD)\n-\n-\tto see what the top commit was.\n-\n- 7) Merging multiple trees\n-\n-\tGit helps you do a three-way merge, which you can expand to\n-\tn-way by repeating the merge procedure arbitrary times until you\n-\tfinally \"commit\" the state.  The normal situation is that you'd\n-\tonly do one three-way merge (two parents), and commit it, but if\n-\tyou like to, you can do multiple parents in one go.\n-\n-\tTo do a three-way merge, you need the two sets of \"commit\"\n-\tobjects that you want to merge, use those to find the closest\n-\tcommon parent (a third \"commit\" object), and then use those\n-\tcommit objects to find the state of the directory (\"tree\"\n-\tobject) at these points.\n-\n-\tTo get the \"base\" for the merge, you first look up the common\n-\tparent of two commits with\n-\n-\t\tmerge-base <commit1> <commit2>\n-\n-\twhich will return you the commit they are both based on.  You\n-\tshould now look up the \"tree\" objects of those commits, which\n-\tyou can easily do with (for example)\n-\n-\t\tcat-file commit <commitname> | head -1\n-\n-\tsince the tree object information is always the first line in a\n-\tcommit object.\n-\n-\tOnce you know the three trees you are going to merge (the one\n-\t\"original\" tree, aka the common case, and the two \"result\" trees,\n-\taka the branches you want to merge), you do a \"merge\" read into\n-\tthe index. This will throw away your old index contents, so you\n-\tshould make sure that you've committed those - in fact you would\n-\tnormally always do a merge against your last commit (which\n-\tshould thus match what you have in your current index anyway).\n-\tTo do the merge, do\n-\n-\t\tread-tree -m <origtree> <target1tree> <target2tree>\n-\n-\twhich will do all trivial merge operations for you directly in\n-\tthe index file, and you can just write the result out with\n-\t\"write-tree\".\n-\n-\tNOTE! Because the merge is done in the index file, and not in\n-\tyour working directory, your working directory will no longer\n-\tmatch your index. You can use \"checkout-cache -f -a\" to make the\n-\teffect of the merge be seen in your working directory.\n+1) working directory -> index\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n-\tNOTE2! Sadly, many merges aren't trivial. If there are files\n-\tthat have been added.moved or removed, or if both branches have\n-\tmodified the same file, you will be left with an index tree that\n-\tcontains \"merge entries\" in it. Such an index tree can _NOT_ be\n-\twritten out to a tree object, and you will have to resolve any\n-\tsuch merge clashes using other tools before you can write out\n-\tthe result.\n+You update the index with information from the working directory with\n+the link:git-update-cache.html[git-update-cache] command.  You\n+generally update the index information by just specifying the filename\n+you want to update, like so:\n+\n+\tgit-update-cache filename\n+\n+but to avoid common mistakes with filename globbing etc, the command\n+will not normally add totally new entries or remove old entries, ie it\n+will normally just update existing cache entryes.\n+\n+To tell git that yes, you really do realize that certain files no\n+longer exist in the archive, or that new files should be added, you\n+should use the \"--remove\" and \"--add\" flags respectively.\n+\n+NOTE! A \"--remove\" flag does _not_ mean that subsequent filenames will\n+necessarily be removed: if the files still exist in your directory\n+structure, the index will be updated with their new status, not\n+removed. The only thing \"--remove\" means is that update-cache will be\n+considering a removed file to be a valid thing, and if the file really\n+does not exist any more, it will update the index accordingly.\n+\n+As a special case, you can also do \"git-update-cache --refresh\", which\n+will refresh the \"stat\" information of each index to match the current\n+stat information. It will _not_ update the object status itself, and\n+it wil only update the fields that are used to quickly test whether an\n+object still matches its old backing store object.\n+\n+2) index -> object database\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+You write your current index file to a \"tree\" object with the program\n+\n+\tgit-write-tree\n+\n+that doesn't come with any options - it will just write out the\n+current index into the set of tree objects that describe that state,\n+and it will return the name of the resulting top-level tree. You can\n+use that tree to re-generate the index at any time by going in the\n+other direction:\n+\n+3) object database -> index\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+You read a \"tree\" file from the object database, and use that to\n+populate (and overwrite - don't do this if your index contains any\n+unsaved state that you might want to restore later!) your current\n+index.  Normal operation is just\n+\n+\t\tgit-read-tree <sha1 of tree>\n+\n+and your index file will now be equivalent to the tree that you saved\n+earlier. However, that is only your _index_ file: your working\n+directory contents have not been modified.\n+\n+4) index -> working directory\n+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n+You update your working directory from the index by \"checking out\"\n+files. This is not a very common operation, since normally you'd just\n+keep your files updated, and rather than write to your working\n+directory, you'd tell the index files about the changes in your\n+working directory (ie \"git-update-cache\").\n+\n+However, if you decide to jump to a new version, or check out somebody\n+elses version, or just restore a previous tree, you'd populate your\n+index file with read-tree, and then you need to check out the result\n+with\n+\t\tgit-checkout-cache filename\n+\n+or, if you want to check out all of the index, use \"-a\".\n+\n+NOTE! git-checkout-cache normally refuses to overwrite old files, so\n+if you have an old version of the tree already checked out, you will\n+need to use the \"-f\" flag (_before_ the \"-a\" flag or the filename) to\n+_force_ the checkout.\n+\n+\n+\n+Finally, there are a few odds and ends which are not purely moving\n+from one representation to the other:\n+\n+5) Tying it all together\n+~~~~~~~~~~~~~~~~~~~~~~~~\n+To commit a tree you have instantiated with \"git-write-tree\", you'd\n+create a \"commit\" object that refers to that tree and the history\n+behind it - most notably the \"parent\" commits that preceded it in\n+history.\n+\n+Normally a \"commit\" has one parent: the previous state of the tree\n+before a certain change was made. However, sometimes it can have two\n+or more parent commits, in which case we call it a \"merge\", due to the\n+fact that such a commit brings together (\"merges\") two or more\n+previous states represented by other commits.\n+\n+In other words, while a \"tree\" represents a particular directory state\n+of a working directory, a \"commit\" represents that state in \"time\",\n+and explains how we got there.\n+\n+You create a commit object by giving it the tree that describes the\n+state at the time of the commit, and a list of parents:\n+\n+\tgit-commit-tree <tree> -p <parent> [-p <parent2> ..]\n+\n+and then giving the reason for the commit on stdin (either through\n+redirection from a pipe or file, or by just typing it at the tty).\n+\n+git-commit-tree will return the name of the object that represents\n+that commit, and you should save it away for later use. Normally,\n+you'd commit a new \"HEAD\" state, and while git doesn't care where you\n+save the note about that state, in practice we tend to just write the\n+result to the file \".git/HEAD\", so that we can always see what the\n+last committed state was.\n+\n+6) Examining the data\n+~~~~~~~~~~~~~~~~~~~~~\n+You can examine the data represented in the object database and the\n+index with various helper tools. For every object, you can use\n+link:git-cat-file.html[git-cat-file] to examine details about the\n+object:\n+\n+\t\tgit-cat-file -t <objectname>\n+\n+shows the type of the object, and once you have the type (which is\n+usually implicit in where you find the object), you can use\n+\n+\t\tgit-cat-file blob|tree|commit <objectname>\n+\n+to show its contents. NOTE! Trees have binary content, and as a result\n+there is a special helper for showing that content, called\n+\"git-ls-tree\", which turns the binary content into a more easily\n+readable form.\n+\n+It's especially instructive to look at \"commit\" objects, since those\n+tend to be small and fairly self-explanatory. In particular, if you\n+follow the convention of having the top commit name in \".git/HEAD\",\n+you can do\n+\n+\t\tgit-cat-file commit $(cat .git/HEAD)\n+\n+to see what the top commit was.\n+\n+7) Merging multiple trees\n+~~~~~~~~~~~~~~~~~~~~~~~~~\n+Git helps you do a three-way merge, which you can expand to n-way by\n+repeating the merge procedure arbitrary times until you finally\n+\"commit\" the state.  The normal situation is that you'd only do one\n+three-way merge (two parents), and commit it, but if you like to, you\n+can do multiple parents in one go.\n+\n+To do a three-way merge, you need the two sets of \"commit\" objects\n+that you want to merge, use those to find the closest common parent (a\n+third \"commit\" object), and then use those commit objects to find the\n+state of the directory (\"tree\" object) at these points.\n+\n+To get the \"base\" for the merge, you first look up the common parent\n+of two commits with\n+\n+\t\tgit-merge-base <commit1> <commit2>\n+\n+which will return you the commit they are both based on.  You should\n+now look up the \"tree\" objects of those commits, which you can easily\n+do with (for example)\n+\n+\t\tgit-cat-file commit <commitname> | head -1\n+\n+since the tree object information is always the first line in a commit\n+object.\n+\n+Once you know the three trees you are going to merge (the one\n+\"original\" tree, aka the common case, and the two \"result\" trees, aka\n+the branches you want to merge), you do a \"merge\" read into the\n+index. This will throw away your old index contents, so you should\n+make sure that you've committed those - in fact you would normally\n+always do a merge against your last commit (which should thus match\n+what you have in your current index anyway).\n+\n+To do the merge, do\n+\n+\t\tgit-read-tree -m <origtree> <target1tree> <target2tree>\n+\n+which will do all trivial merge operations for you directly in the\n+index file, and you can just write the result out with \"git-write-tree\".\n+\n+NOTE! Because the merge is done in the index file, and not in your\n+working directory, your working directory will no longer match your\n+index. You can use \"git-checkout-cache -f -a\" to make the effect of\n+the merge be seen in your working directory.\n+\n+NOTE2! Sadly, many merges aren't trivial. If there are files that have\n+been added.moved or removed, or if both branches have modified the\n+same file, you will be left with an index tree that contains \"merge\n+entries\" in it. Such an index tree can _NOT_ be written out to a tree\n+object, and you will have to resolve any such merge clashes using\n+other tools before you can write out the result.\n\n-\t[ fixme: talk about resolving merges here ]\n\n+[ fixme: talk about resolving merges here ]\n-\nTo unsubscribe from this list: send the line \"unsubscribe git\" in\nthe body of a message to majordomo@vger.kernel.org\nMore majordomo info at  http://vger.kernel.org/majordomo-info.html\n\n"},{"id":"3251","messageId":"20050513221306.GB32232@pasky.ji.cz","threadId":"592","inReplyTo":"4283CB19.3050208@dgreaves.com","subject":"Re: [PATCH] update README and #include in git.txt","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-13T22:13:06Z","receivedAt":"2005-05-13T22:13:06Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Thu, May 12, 2005 at 11:31:05PM CEST, I got a letter\nwhere David Greaves <david@dgreaves.com> told me that...\n> Makefile understands the includes git.txt #includes README\n> README reformatted to asciidoc to allow inclusion in git.txt\n> \n> Signed-off-by: David Greaves <david@dgreaves.com>\n\nIs it just me or this commit message is really weird? :-)\n\n> Index: README\n> ===================================================================\n> --- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/README  (mode:100644)\n> +++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/README  (mode:100644)\n> @@ -1,9 +1,13 @@\n> +////////////////////////////////////////////////////////////////\n> +\tGIT - the stupid content tracker\n> \n> \n> -\n> -\tGIT - the stupid content tracker\n> +Note that this README is written in asciidoc format and is #include'd\n> +in the git.txt docs\n> \n> \n> +The rest of this README is #included in the git.txt file\n> +////////////////////////////////////////////////////////////////\n>  \"git\" can mean anything, depending on your mood.\n> \n>   - random three-letter combination that is pronounceable, and not\n\nI'd probably prefer this being much less prominent. Can it be rather at\nthe bottom of the file?\n\n> -the object (i.e. how it is used, and how it can refer to other objects).\n> -There are currently three different object types: \"blob\", \"tree\" and\n> -\"commit\".\n> +the object (ie how it is used, and how it can refer to other objects).\n> +There are currently four different object types: \"blob\", \"tree\",\n> +\"commit\" and \"tag\".\n\nYou're reintroducing the \"typos\" fixed before, apparently.\n\n>  A \"blob\" object cannot refer to any other object, and is, like the tag\n>  implies, a pure storage object containing some user data.  It is used to\n> @@ -48,7 +50,7 @@\n>  directory structure. In addition, a tree object can refer to other tree\n>  objects, thus creating a directory hierarchy.\n> \n> -Finally, a \"commit\" object ties such directory hierarchies together into\n> +A \"commit\" object ties such directory hierarchies together into\n>  a DAG of revisions - each \"commit\" is associated with exactly one tree\n>  (the directory hierarchy at the time of the commit). In addition, a\n>  \"commit\" refers to one or more \"parent\" commit objects that describe the\n> @@ -62,12 +64,17 @@\n>  just going to confuse people.  So aim for the notion of \"one root object\n>  per project\", even if git itself does not enforce that.\n> \n> +A \"tag\" object symbolically identifies and can be used to sign other\n> +objects. It contains the identifier and type of another object, a\n> +symbolic name (of course!) and, optionally, a signature.\n> +\n\nI think those changes should be either sent as a separate patch or noted\nas being done in the commit message.\n\n> @@ -245,216 +274,209 @@\n> \n> \n> \n> -\tThe Workflow\n> -\n> -\n> +The Workflow\n> +------------\n\n\nCannot at least the newlines be preserved?\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"},{"id":"3255","messageId":"42852A44.7010806@dgreaves.com","threadId":"592","inReplyTo":"20050513221306.GB32232@pasky.ji.cz","subject":"Re: [PATCH] update README and #include in git.txt","fromName":"David Greaves","fromEmail":"david@dgreaves.com","sentAt":"2005-05-13T22:29:24Z","receivedAt":"2005-05-13T22:29:24Z","isPatch":true,"sender":{"key":"david@dgreaves.com","avatar":"https://gravatar.com/avatar/ca67bad50999edcdd137c9a65da2381557d175bea99ae956afdabc5785e42b79?d=mp&s=160"},"body":"Petr Baudis wrote:\n\n>Dear diary, on Thu, May 12, 2005 at 11:31:05PM CEST, I got a letter\n>where David Greaves <david@dgreaves.com> told me that...\n>  \n>\n>>Makefile understands the includes git.txt #includes README\n>>README reformatted to asciidoc to allow inclusion in git.txt\n>>\n>>Signed-off-by: David Greaves <david@dgreaves.com>\n>>    \n>>\n>\n>Is it just me or this commit message is really weird? :-)\n>  \n>\nI know, I saw it when I pushed send. Somehow a \\n became a space... I\nblame vi. Should be:\n\nMakefile understands the includes\ngit.txt #includes README\nREADME reformatted to asciidoc to allow inclusion in git.txt\n\n>  \n>\n>>Index: README\n>>===================================================================\n>>--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/README  (mode:100644)\n>>+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/README  (mode:100644)\n>>@@ -1,9 +1,13 @@\n>>+////////////////////////////////////////////////////////////////\n>>+\tGIT - the stupid content tracker\n>>\n>>\n>>-\n>>-\tGIT - the stupid content tracker\n>>+Note that this README is written in asciidoc format and is #include'd\n>>+in the git.txt docs\n>>\n>>\n>>+The rest of this README is #included in the git.txt file\n>>+////////////////////////////////////////////////////////////////\n>> \"git\" can mean anything, depending on your mood.\n>>\n>>  - random three-letter combination that is pronounceable, and not\n>>    \n>>\n>\n>I'd probably prefer this being much less prominent. Can it be rather at\n>the bottom of the file?\n>  \n>\nIf you mean the header in the ///'s?\nyes - but I wanted editors to realise it is asciidoc so kept it at the top.\nIt could also be toned down by using fewer ////s - but that looked a bit\nodd.\n(the /// /// lines act as comment block markers so asciidoc ignores the\nheader\n\nOr the \"git can mean anything\" speech?\nThat's how it was originally.\n\n>  \n>\n>>-the object (i.e. how it is used, and how it can refer to other objects).\n>>-There are currently three different object types: \"blob\", \"tree\" and\n>>-\"commit\".\n>>+the object (ie how it is used, and how it can refer to other objects).\n>>+There are currently four different object types: \"blob\", \"tree\",\n>>+\"commit\" and \"tag\".\n>>    \n>>\n>\n>You're reintroducing the \"typos\" fixed before, apparently.\n>  \n>\nI didn't notice the i.e. vs ie - I'm not that bothered ;)\n\n>  \n>\n>> A \"blob\" object cannot refer to any other object, and is, like the tag\n>> implies, a pure storage object containing some user data.  It is used to\n>>@@ -48,7 +50,7 @@\n>> directory structure. In addition, a tree object can refer to other tree\n>> objects, thus creating a directory hierarchy.\n>>\n>>-Finally, a \"commit\" object ties such directory hierarchies together into\n>>+A \"commit\" object ties such directory hierarchies together into\n>> a DAG of revisions - each \"commit\" is associated with exactly one tree\n>> (the directory hierarchy at the time of the commit). In addition, a\n>> \"commit\" refers to one or more \"parent\" commit objects that describe the\n>>@@ -62,12 +64,17 @@\n>> just going to confuse people.  So aim for the notion of \"one root object\n>> per project\", even if git itself does not enforce that.\n>>\n>>+A \"tag\" object symbolically identifies and can be used to sign other\n>>+objects. It contains the identifier and type of another object, a\n>>+symbolic name (of course!) and, optionally, a signature.\n>>+\n>>    \n>>\n>\n>I think those changes should be either sent as a separate patch or noted\n>as being done in the commit message.\n>  \n>\nmakes sense.\nI'd rather note them in the message if that's OK\n\n>  \n>\n>>@@ -245,216 +274,209 @@\n>>\n>>\n>>\n>>-\tThe Workflow\n>>-\n>>-\n>>+The Workflow\n>>+------------\n>>    \n>>\n>\n>\n>Cannot at least the newlines be preserved?\n>  \n>\nYes - I must have been in an anti-whitespace mood.\n\nWill see to this in the am...\n\nDavid\n\n-- \n\n"},{"id":"3263","messageId":"20050513225757.GH32232@pasky.ji.cz","threadId":"592","inReplyTo":"42852A44.7010806@dgreaves.com","subject":"Re: [PATCH] update README and #include in git.txt","fromName":"Petr Baudis","fromEmail":"pasky@ucw.cz","sentAt":"2005-05-13T22:57:57Z","receivedAt":"2005-05-13T22:57:57Z","isPatch":true,"sender":{"key":"pasky@ucw.cz","avatar":"https://avatars.githubusercontent.com/u/18439?v=4"},"body":"Dear diary, on Sat, May 14, 2005 at 12:29:24AM CEST, I got a letter\nwhere David Greaves <david@dgreaves.com> told me that...\n> >>Index: README\n> >>===================================================================\n> >>--- 3c79088f1832d78012ccdb63e5da1ab88fcf408e/README  (mode:100644)\n> >>+++ e0e578bb02a7d8db1c105fddf5b5168ad0c79088/README  (mode:100644)\n> >>@@ -1,9 +1,13 @@\n> >>+////////////////////////////////////////////////////////////////\n> >>+\tGIT - the stupid content tracker\n> >>\n> >>\n> >>-\n> >>-\tGIT - the stupid content tracker\n> >>+Note that this README is written in asciidoc format and is #include'd\n> >>+in the git.txt docs\n> >>\n> >>\n> >>+The rest of this README is #included in the git.txt file\n> >>+////////////////////////////////////////////////////////////////\n> >> \"git\" can mean anything, depending on your mood.\n> >>\n> >>  - random three-letter combination that is pronounceable, and not\n> >>    \n> >>\n> >\n> >I'd probably prefer this being much less prominent. Can it be rather at\n> >the bottom of the file?\n> >  \n> >\n> If you mean the header in the ///'s?\n> yes - but I wanted editors to realise it is asciidoc so kept it at the top.\n\nBut it's called README, not EDITME. And I think it's cluttering for the\nreaders.\n\n> >You're reintroducing the \"typos\" fixed before, apparently.\n> >  \n> >\n> I didn't notice the i.e. vs ie - I'm not that bothered ;)\n\nBut there were other typo fixes there and the big reindenting won't show\nup any further changes to the text. I don't want to lose them so I'm\nconcerned now.\n\n-- \n\t\t\t\tPetr \"Pasky\" Baudis\nStuff: http://pasky.or.cz/\nC++: an octopus made by nailing extra legs onto a dog. -- Steve Taylor\n"}]}