{"thread":{"id":"9922","subject":"[rfc] git submodules howto","startedAt":"2007-09-18T10:55:38Z","lastAt":"2007-09-24T08:30:25Z","messageCount":28,"participants":["Miklos Vajna","Johannes Schindelin","Michael Smith","J. Bruce Fields","Junio C Hamano","Sven Verdoolaege","Joel Becker","Uwe Kleine-König"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"53446","messageId":"20070918105538.GL19019@genesis.frugalware.org","threadId":"9922","inReplyTo":null,"subject":"[rfc] git submodules howto","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-18T10:55:38Z","receivedAt":"2007-09-18T10:55:38Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"hi,\n\ni saw several \"is there any step by step howto on how to use git\nsubmodules?\" question on irc, and as far as i think there is none\navailable at the moment\n\nhere is how i use it at the moment:\n\n$ mkdir lib\n$ cd lib\n$ git init\nInitialized empty Git repository in .git/\n$ echo \"libmakefile\" > Makefile\n$ dg add Makefile\n$ git commit -m \"libmakefile\"\nCreated initial commit 57c1dce: libmakefile\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 Makefile\n$ cd ..\n$ mkdir main\n$ cd main\n$ git init\nInitialized empty Git repository in .git/\n$ echo \"main makefile\" > Makefile\n$ git add Makefile\n$ git commit -m \"main makefile\"\nCreated initial commit 8935291: main makefile\n 1 files changed, 1 insertions(+), 0 deletions(-)\n create mode 100644 Makefile\n$ git submodule add ../lib lib\nInitialized empty Git repository in /home/vmiklos/scm/git/sub/main/lib/.git/\n0 blocks\n$ git commit -m \"added lib submodule\"\nCreated commit 9dbfedf: added lib submodule\n 2 files changed, 4 insertions(+), 0 deletions(-)\n create mode 100644 .gitmodules\n create mode 160000 lib\n$ cd ..\n$ git clone main cloned\nInitialized empty Git repository in /home/vmiklos/scm/git/sub/cloned/.git/\n0 blocks\n$ cd cloned\n$ git submodule init\nSubmodule 'lib' (/home/vmiklos/scm/git/sub/lib/.git) registered for path 'lib'\n$ git submodule update\nInitialized empty Git repository in /home/vmiklos/scm/git/sub/cloned/lib/.git/\n0 blocks\nSubmodule path 'lib': checked out '57c1dce0e083e9ee50d06111d6aa1523116c2e15'\n$ cat Makefile\nmain makefile\n$ cat lib/Makefile\nlibmakefile\n\nmy questions:\n\n1) is this correct? :) i use it and it seem to do what i except, but\nmaybe it's not correct\n\n2) does this worth adding to the documentation? maybe to a .txt under\nDocumentation/howto? or to git-submodule.txt?\n\nthanks,\n- VMiklos\n"},{"id":"53460","messageId":"Pine.LNX.4.64.0709181303180.28586@racer.site","threadId":"9922","inReplyTo":"20070918105538.GL19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-18T12:03:38Z","receivedAt":"2007-09-18T12:03:38Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 18 Sep 2007, Miklos Vajna wrote:\n\n> i saw several \"is there any step by step howto on how to use git \n> submodules?\" question on irc, and as far as i think there is none \n> available at the moment\n\nAFAICT there is one, on the git Wiki, since yesterday.\n\nCiao,\nDscho\n"},{"id":"53461","messageId":"Pine.LNX.4.64.0709180808210.6203@juice.ott.cti.com","threadId":"9922","inReplyTo":"20070918105538.GL19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"Michael Smith","fromEmail":"msmith@cbnco.com","sentAt":"2007-09-18T12:10:21Z","receivedAt":"2007-09-18T12:10:21Z","isPatch":false,"sender":{"key":"msmith@cbnco.com","avatar":null},"body":"On Tue, 18 Sep 2007, Miklos Vajna wrote:\n\n> 1) is this correct? :) i use it and it seem to do what i except, but\n> maybe it's not correct\n\nHi Miklos,\n\nI had the same question, but you and I are both using it in a similar way \nso that's encouraging.\n\nI put something in the Wiki the other day.\n\nhttp://git.or.cz/gitwiki/GitSubmoduleTutorial\n\nMike\n"},{"id":"53478","messageId":"20070918132940.GC12120@fieldses.org","threadId":"9922","inReplyTo":"20070918105538.GL19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-09-18T13:29:40Z","receivedAt":"2007-09-18T13:29:40Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Tue, Sep 18, 2007 at 12:55:38PM +0200, Miklos Vajna wrote:\n> 1) is this correct? :) i use it and it seem to do what i except, but\n> maybe it's not correct\n\nI'm not able to answer that question.\n\n> 2) does this worth adding to the documentation? maybe to a .txt under\n> Documentation/howto? or to git-submodule.txt?\n\nCould you add it as a new chapter to user-manual.txt (probably just\nafter the \"git concepts\" chapter), and then add links to that chapter\nfrom git-submodule(1) and gitmodules(5)?\n\n--b.\n"},{"id":"53491","messageId":"20070918154734.GP19019@genesis.frugalware.org","threadId":"9922","inReplyTo":"20070918132940.GC12120@fieldses.org","subject":"Re: [rfc] git submodules howto","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-18T15:47:34Z","receivedAt":"2007-09-18T15:47:34Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Tue, Sep 18, 2007 at 09:29:40AM -0400, \"J. Bruce Fields\" <bfields@fieldses.org> wrote:\n> > 2) does this worth adding to the documentation? maybe to a .txt under\n> > Documentation/howto? or to git-submodule.txt?\n> \n> Could you add it as a new chapter to user-manual.txt (probably just\n> after the \"git concepts\" chapter), and then add links to that chapter\n> from git-submodule(1) and gitmodules(5)?\n\nhm, i did not know about the wiki page Michael created yesterday. so i\ndon't know what's the rule in case: if something is already in the wiki\nthen should or should not it be added to the 'official docs'?\n\n- VMiklos\n"},{"id":"53494","messageId":"20070918155529.GD18476@fieldses.org","threadId":"9922","inReplyTo":"20070918154734.GP19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-09-18T15:55:29Z","receivedAt":"2007-09-18T15:55:29Z","isPatch":false,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Tue, Sep 18, 2007 at 05:47:34PM +0200, Miklos Vajna wrote:\n> On Tue, Sep 18, 2007 at 09:29:40AM -0400, \"J. Bruce Fields\" <bfields@fieldses.org> wrote:\n> > > 2) does this worth adding to the documentation? maybe to a .txt under\n> > > Documentation/howto? or to git-submodule.txt?\n> > \n> > Could you add it as a new chapter to user-manual.txt (probably just\n> > after the \"git concepts\" chapter), and then add links to that chapter\n> > from git-submodule(1) and gitmodules(5)?\n> \n> hm, i did not know about the wiki page Michael created yesterday. so i\n> don't know what's the rule in case: if something is already in the wiki\n> then should or should not it be added to the 'official docs'?\n\nIt should.  We also need submodules documentation for the \"official\"\ndocumentation.\n\nIf you want to base that work off of that wiki page instead of your\noriginal email, that's fine.  Just make sure you get Michael's\npermission first.\n\n--b.\n"},{"id":"53495","messageId":"20070918161112.GR19019@genesis.frugalware.org","threadId":"9922","inReplyTo":"20070918155529.GD18476@fieldses.org","subject":"Re: [rfc] git submodules howto","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-18T16:11:12Z","receivedAt":"2007-09-18T16:11:12Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"[ adding Michael to CC. ]\n\nOn Tue, Sep 18, 2007 at 11:55:29AM -0400, \"J. Bruce Fields\" <bfields@fieldses.org> wrote:\n> > hm, i did not know about the wiki page Michael created yesterday. so i\n> > don't know what's the rule in case: if something is already in the wiki\n> > then should or should not it be added to the 'official docs'?\n> \n> It should.  We also need submodules documentation for the \"official\"\n> documentation.\n\nokay.\n\n> If you want to base that work off of that wiki page instead of your\n> original email, that's fine.  Just make sure you get Michael's\n> permission first.\n\nMichael, i think the wiki version is better as my example does not\ncontain any extra to the wiki version. is it ok if i would send a patch\nto include your work in the official docs?\n\ni'm not sure how should i mention you, maybe in the commit message?\n\n- VMiklos\n"},{"id":"53498","messageId":"Pine.LNX.4.64.0709181405120.6203@juice.ott.cti.com","threadId":"9922","inReplyTo":"20070918161112.GR19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"Michael Smith","fromEmail":"msmith@cbnco.com","sentAt":"2007-09-18T18:12:17Z","receivedAt":"2007-09-18T18:12:17Z","isPatch":false,"sender":{"key":"msmith@cbnco.com","avatar":null},"body":"On Tue, 18 Sep 2007, Miklos Vajna wrote:\n\n> Michael, i think the wiki version is better as my example does not\n> contain any extra to the wiki version. is it ok if i would send a patch\n> to include your work in the official docs?\n\nThanks, that would be great.\n\n> i'm not sure how should i mention you, maybe in the commit message?\n\nMaybe signed-off-by is appropriate? Otherwise, don't worry about it.\n\nMike\n"},{"id":"53586","messageId":"20070919174250.GC16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"Pine.LNX.4.64.0709181405120.6203@juice.ott.cti.com","subject":"[PATCH] User Manual: add a chapter for submodules","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-19T17:42:50Z","receivedAt":"2007-09-19T17:42:50Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Michael Smith <msmith@cbnco.com>\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nOn Tue, Sep 18, 2007 at 02:12:17PM -0400, Michael Smith <msmith@cbnco.com> wrote:\n> On Tue, 18 Sep 2007, Miklos Vajna wrote:\n>\n> > Michael, i think the wiki version is better as my example does not\n> > contain any extra to the wiki version. is it ok if i would send a patch\n> > to include your work in the official docs?\n>\n> Thanks, that would be great.\n\nhere it is. this version is a bit shorter than the wiki one, but i think it\ndoes not contain less useful info\n\n Documentation/user-manual.txt |  175 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 175 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex ecb2bf9..ce0cf38 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -3155,6 +3155,181 @@ a tree which you are in the process of working on.\n If you blow the index away entirely, you generally haven't lost any\n information as long as you have the name of the tree that it described.\n \n+[[submodules]]\n+Submodules\n+==========\n+\n+This tutorial explains how to create and publish a repository with submodules\n+using the gitlink:git-submodule[1] command.\n+\n+Submodules maintain their own identity; the submodule support just stores the\n+submodule repository location and commit ID, so other developers who clone the\n+superproject can easily clone all the submodules at the same revision.\n+\n+To see how submodule support works, create (for example) four example\n+repository that can be used later as a submodule:\n+\n+-------------------------------------------------\n+$ mkdir ~/git\n+$ cd ~/git\n+$ for i in a b c d\n+do\n+\tmkdir $i\n+\tcd $i\n+\tgit init\n+\techo \"module $i\" > $i.txt\n+\tgit add $i.txt\n+\tgit commit -m \"Initial commit, submodule $mod\"\n+\tcd ..\n+done\n+-------------------------------------------------\n+\n+Now create the superproject and add all the submodules:\n+\n+-------------------------------------------------\n+$ mkdir super\n+$ cd super\n+$ git init\n+$ echo hi > super.txt\n+$ git add super.txt\n+$ git commit -m \"Initial commit of empty superproject\"\n+$ for i in a b c d\n+do\n+\tgit submodule add ~/git/$i\n+done\n+-------------------------------------------------\n+\n+See what files `git submodule` created:\n+\n+-------------------------------------------------\n+$ ls -a\n+.  ..  .git  .gitmodules  a  b  c  d  super.txt\n+-------------------------------------------------\n+\n+The `git submodule add` command does a couple of things:\n+\n+- It clones the submodule under the current directory and by default checks out\n+  the master branch.\n+- It adds the submodule's clone path to the `.gitmodules` file and adds this\n+  file to the index, ready to be committed.\n+- It adds the submodule's current commit ID to the index, ready to be\n+  committed.\n+\n+Commit the superproject:\n+\n+-------------------------------------------------\n+$ git commit -m \"Add submodules a, b, c, d.\"\n+-------------------------------------------------\n+\n+Now clone the superproject:\n+\n+-------------------------------------------------\n+$ cd ..\n+$ git clone super cloned\n+$ cd cloned\n+-------------------------------------------------\n+\n+The submodule directories are there, but they're empty:\n+\n+-------------------------------------------------\n+$ ls -a a\n+.  ..\n+$ git submodule status\n+-d266b9873ad50488163457f025db7cdd9683d88b a\n+-e81d457da15309b4fef4249aba9b50187999670d b\n+-c1536a972b9affea0f16e0680ba87332dc059146 c\n+-d96249ff5d57de5de093e6baff9e0aafa5276a74 d\n+-------------------------------------------------\n+\n+Pulling down the submodules is a two-step process. First run `git submodule\n+init` to add the submodule repository URLs to `.git/config`:\n+\n+-------------------------------------------------\n+$ git submodule init\n+-------------------------------------------------\n+\n+Now use `git submodule update` to clone the repositories and check out the\n+commits specified in the superproject:\n+\n+-------------------------------------------------\n+$ git submodule update\n+$ cd a\n+$ ls -a\n+.  ..  .git  a.txt\n+-------------------------------------------------\n+\n+One major difference between `git submodule update` and `git submodule add` is\n+that `git submodule update` checks out a specific commit, rather than the tip\n+of a branch. It's like checking out a tag: the head is detached, so you're not\n+working on a branch.\n+\n+-------------------------------------------------\n+$ git branch\n+* (no branch)\n+  master\n+-------------------------------------------------\n+\n+If you want to make a change within a submodule, you should first check out a\n+branch, make your changes, publish the change within the submodule, and then\n+update the superproject to reference the new commit:\n+\n+-------------------------------------------------\n+$ git branch\n+* (no branch)\n+  master\n+$ git checkout master\n+$ echo \"adding a line again\" >> a.txt\n+$ git commit -a -m \"Updated the submodule from within the superproject.\"\n+$ git push\n+$ cd ..\n+$ git add a\n+$ git commit -m \"Updated submodule a.\"\n+$ git push\n+-------------------------------------------------\n+\n+NOTE: This means that you have to run `git submodule update` after `git pull`\n+if you want to update the subprojects, too.\n+\n+Problems with submodules\n+------------------------\n+\n+Always publish the submodule change before publishing the change to the\n+superproject that references it. If you forget to publish the submodule change,\n+others won't be able to clone the repository:\n+\n+-------------------------------------------------\n+$ echo i added another line to this file >> a.txt\n+$ git commit -a -m \"doing it wrong this time\"\n+$ cd ..\n+$ git add a\n+$ git commit -m \"Updated submodule a again.\"\n+$ git push\n+$ cd ~/git/cloned\n+$ git pull\n+$ git submodule update\n+error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\n+Did you forget to 'git add'?\n+Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'\n+-------------------------------------------------\n+\n+It's not safe to run `git submodule update` if you've made changes within a\n+submodule. They will be silently overwritten:\n+\n+-------------------------------------------------\n+$ cat a.txt\n+module a\n+$ echo line added from private2 >> a.txt\n+$ git commit -a -m \"line added inside private2\"\n+$ cd ..\n+$ git submodule update\n+Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b'\n+$ cd a\n+$ cat a.txt\n+module a\n+-------------------------------------------------\n+\n+NOTE: The changes are still visible in the submodule's reflog.\n+\n [[low-level-operations]]\n Low-level git operations\n ========================\n-- \n1.5.3.1.1.g1e61-dirty\n"},{"id":"53598","messageId":"7vbqbyphil.fsf@gitster.siamese.dyndns.org","threadId":"9922","inReplyTo":"20070919174250.GC16235@genesis.frugalware.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-19T19:44:18Z","receivedAt":"2007-09-19T19:44:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> Signed-off-by: Michael Smith <msmith@cbnco.com>\n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n\nThanks.\n\n> diff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\n> index ecb2bf9..ce0cf38 100644\n> --- a/Documentation/user-manual.txt\n> +++ b/Documentation/user-manual.txt\n> @@ -3155,6 +3155,181 @@ a tree which you are in the process of working on.\n>  If you blow the index away entirely, you generally haven't lost any\n>  information as long as you have the name of the tree that it described.\n>  \n> +[[submodules]]\n> +Submodules\n> +==========\n> +\n> +This tutorial explains how to create and publish a repository with submodules\n> +using the gitlink:git-submodule[1] command.\n> +\n> +Submodules maintain their own identity; the submodule support just stores the\n> +submodule repository location and commit ID, so other developers who clone the\n> +superproject can easily clone all the submodules at the same revision.\n> +\n> +To see how submodule support works, create (for example) four example\n> +repository that can be used later as a submodule:\n\ns/repository/repositories/;\n\n> +-------------------------------------------------\n> +$ mkdir ~/git\n> +$ cd ~/git\n> +$ for i in a b c d\n> +do\n> +\tmkdir $i\n> +\tcd $i\n> +\tgit init\n> +\techo \"module $i\" > $i.txt\n> +\tgit add $i.txt\n> +\tgit commit -m \"Initial commit, submodule $mod\"\n\ns/\\$mod/$i/;\n\n> +\tcd ..\n> +done\n> +-------------------------------------------------\n> +\n> +Now create the superproject and add all the submodules:\n> +\n> +-------------------------------------------------\n> +$ mkdir super\n> +$ cd super\n> +$ git init\n> +$ echo hi > super.txt\n> +$ git add super.txt\n> +$ git commit -m \"Initial commit of empty superproject\"\n\nThis is not *empty*; do you even need this step?\n\n> +$ for i in a b c d\n> +do\n> +\tgit submodule add ~/git/$i\n> +done\n> +-------------------------------------------------\n> +\n> +See what files `git submodule` created:\n> +\n> +-------------------------------------------------\n> +$ ls -a\n> +.  ..  .git  .gitmodules  a  b  c  d  super.txt\n> +-------------------------------------------------\n> +\n> +The `git submodule add` command does a couple of things:\n> +\n> +- It clones the submodule under the current directory and by default checks out\n> +  the master branch.\n> +- It adds the submodule's clone path to the `.gitmodules` file and adds this\n> +  file to the index, ready to be committed.\n> +- It adds the submodule's current commit ID to the index, ready to be\n> +  committed.\n> +\n> +Commit the superproject:\n> +\n> +-------------------------------------------------\n> +$ git commit -m \"Add submodules a, b, c, d.\"\n> +-------------------------------------------------\n\ns/c, d./c and d./;\n\n> +\n> +Now clone the superproject:\n> +\n> +-------------------------------------------------\n> +$ cd ..\n> +$ git clone super cloned\n> +$ cd cloned\n> +-------------------------------------------------\n> +\n> +The submodule directories are there, but they're empty:\n> +\n> +-------------------------------------------------\n> +$ ls -a a\n> +.  ..\n> +$ git submodule status\n> +-d266b9873ad50488163457f025db7cdd9683d88b a\n> +-e81d457da15309b4fef4249aba9b50187999670d b\n> +-c1536a972b9affea0f16e0680ba87332dc059146 c\n> +-d96249ff5d57de5de093e6baff9e0aafa5276a74 d\n> +-------------------------------------------------\n\nYou might want to mention...\n\n    Note: the commit object names shown above would be different for\n    you, but they should match the HEAD commit object names of your\n    repositories.  You can check it by doing:\n\n    $ git ls-remote ../a\n\n> +Pulling down the submodules is a two-step process. First run `git submodule\n> +init` to add the submodule repository URLs to `.git/config`:\n> +\n> +-------------------------------------------------\n> +$ git submodule init\n> +-------------------------------------------------\n> +\n> +Now use `git submodule update` to clone the repositories and check out the\n> +commits specified in the superproject:\n> +\n> +-------------------------------------------------\n> +$ git submodule update\n> +$ cd a\n> +$ ls -a\n> +.  ..  .git  a.txt\n> +-------------------------------------------------\n> +\n> +One major difference between `git submodule update` and `git submodule add` is\n> +that `git submodule update` checks out a specific commit, rather than the tip\n> +of a branch. It's like checking out a tag: the head is detached, so you're not\n> +working on a branch.\n> +\n> +-------------------------------------------------\n> +$ git branch\n> +* (no branch)\n> +  master\n> +-------------------------------------------------\n> +\n> +If you want to make a change within a submodule, you should first check out a\n> +branch, make your changes, publish the change within the submodule, and then\n> +update the superproject to reference the new commit:\n> +\n> +-------------------------------------------------\n> +$ git branch\n> +* (no branch)\n> +  master\n> +$ git checkout master\n\nI am not so sure about this advice.  Don't you want to see how\nthe detached HEAD and 'master' (or any other branches) are\nrelated before doing this?  You might even want to create a\n\"fix-up\" branch that is rooted at the detached HEAD if the\nchange you are making is to fix minor details of the submodule\nto suit what superproject wants (i.e. \"little feature that is\napplicable to the submodule as a standalone project, meant to\nbe pushed back to the submodule upstream\").\n\n> +$ echo \"adding a line again\" >> a.txt\n> +$ git commit -a -m \"Updated the submodule from within the superproject.\"\n> +$ git push\n> +$ cd ..\n> +$ git add a\n\nBefore doing this \"git add\", it would be educational to have the\nuser do\n\n    $ git diff\n\nwhich would say that now the submodule is being updated.\n\n\n> +$ git commit -m \"Updated submodule a.\"\n> +$ git push\n> +-------------------------------------------------\n> +\n> +NOTE: This means that you have to run `git submodule update` after `git pull`\n> +if you want to update the subprojects, too.\n\nI do not quite understand this note.  I do understand the part\nafter \"that you have to\", but I do not know how the above\nexample relates to that --- iow, the above example does not\nseem to \"mean\" such thing to me.\n\nAlso \"submodule\" is used consistently in the rest of the\ndocument but this sentence talks about \"subproject\".\n\n> +Problems with submodules\n> +------------------------\n\nThe list is good, but are they Problems or pitfalls to watch out\nfor?\n\n> +Always publish the submodule change before publishing the change to the\n> +superproject that references it. If you forget to publish the submodule change,\n> +others won't be able to clone the repository:\n\nThe same caution applies not to rewind branches in submodule\nbeyond commits that were ever recorded in any superproject.\n\n> +-------------------------------------------------\n> +$ echo i added another line to this file >> a.txt\n> +$ git commit -a -m \"doing it wrong this time\"\n\nIt is not clear in which repository you are supposed to try this\ncommand in the example sequence, as we crossed the section\nboundary.  I am _guessing_ that the above two commands are to be\nrun inside ~/git/cloned-2/a after redoing ~/git/cloned-2 the\nsame way as you did ~/git/cloned, but you may want to make it\nclear.\n\n> +$ cd ..\n> +$ git add a\n> +$ git commit -m \"Updated submodule a again.\"\n> +$ git push\n> +$ cd ~/git/cloned\n> +$ git pull\n> +$ git submodule update\n> +error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\n> +Did you forget to 'git add'?\n\nI sense there is a bug in \"git submodule update\" here.  I do not\nhave time to look at what it's doing right now, but this is a\nsymptom of running:\n\n    $ git checkout 261dfac35...\n\nwithout checking if that is a valid commit object name, and git\ncheckout cannot decide if the request is about detaching the\nhead at commit 261dfac35 or checking the path 261dfac35 out of\nthe current index.  Porcelains should check with \"cat-file -t\"\nfirst.\n\nIn addition we probably would want to teach \"git checkout\" about\nthe \"--\" separator, so that this can be disambiguated like this:\n\n    $ git checkout 261dfac35 --\n\n> +Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'\n> +-------------------------------------------------\n> +\n> +It's not safe to run `git submodule update` if you've made changes within a\n> +submodule. They will be silently overwritten:\n\nYou want to distinguish two cases here.  Local uncommitted\nchanges, and committed changes.  The latter case is switched\naway without too much noise, which is what you are demonstrating\nhere.  I _think_ local uncommitted changes will not be\noverwritten at all, unless \"submodule update\" does \"reset\n--hard\", which I suspect it doesn't.\n\n> +-------------------------------------------------\n> +$ cat a.txt\n> +module a\n> +$ echo line added from private2 >> a.txt\n> +$ git commit -a -m \"line added inside private2\"\n> +$ cd ..\n> +$ git submodule update\n> +Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b'\n> +$ cd a\n> +$ cat a.txt\n> +module a\n> +-------------------------------------------------\n> +\n> +NOTE: The changes are still visible in the submodule's reflog.\n> +\n>  [[low-level-operations]]\n>  Low-level git operations\n>  ========================\n> -- \n> 1.5.3.1.1.g1e61-dirty\n"},{"id":"53602","messageId":"20070919203014.GI5946@fieldses.org","threadId":"9922","inReplyTo":"7vbqbyphil.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"J. Bruce Fields","fromEmail":"bfields@fieldses.org","sentAt":"2007-09-19T20:30:14Z","receivedAt":"2007-09-19T20:30:14Z","isPatch":true,"sender":{"key":"bfields@citi.umich.edu","avatar":null},"body":"On Wed, Sep 19, 2007 at 12:44:18PM -0700, Junio C Hamano wrote:\n> Also \"submodule\" is used consistently in the rest of the\n> document but this sentence talks about \"subproject\".\n\nI never liked the terms \"submodule\" or \"subproject\" much--it seems to\nfocus attention in the wrong place.  it's the \"superproject\" that's the\nnew and interesting thing here, while the submodules themselves are all\njust standard git projects, right?\n\nBut I guess that's kind of a silly complaint, and late besides.\n\n--b.\n"},{"id":"53605","messageId":"20070919210022.GJ3619MdfPADPa@greensroom.kotnet.org","threadId":"9922","inReplyTo":"20070919174250.GC16235@genesis.frugalware.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"Sven Verdoolaege","fromEmail":"skimo@kotnet.org","sentAt":"2007-09-19T21:00:22Z","receivedAt":"2007-09-19T21:00:22Z","isPatch":true,"sender":{"key":"skimo@kotnet.org","avatar":null},"body":"On Wed, Sep 19, 2007 at 07:42:50PM +0200, Miklos Vajna wrote:\n> +Submodules maintain their own identity; the submodule support just stores the\n> +submodule repository location and commit ID, so other developers who clone the\n> +superproject can easily clone all the submodules at the same revision.\n\n[..]\n\n> +-------------------------------------------------\n> +$ mkdir super\n> +$ cd super\n> +$ git init\n> +$ echo hi > super.txt\n> +$ git add super.txt\n> +$ git commit -m \"Initial commit of empty superproject\"\n> +$ for i in a b c d\n> +do\n> +\tgit submodule add ~/git/$i\n> +done\n> +-------------------------------------------------\n\nYou may want to warn the reader not to use local URLs here if they\nplan to publish their superproject.\n\n> +It's not safe to run `git submodule update` if you've made changes within a\n> +submodule. They will be silently overwritten:\n\nThis is only true if they didn't follow your advise of checking out\na branch first.\n\nskimo\n"},{"id":"53614","messageId":"20070920000107.GH16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"7vbqbyphil.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] User Manual: add a chapter for submodules","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-20T00:01:07Z","receivedAt":"2007-09-20T00:01:07Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Michael Smith <msmith@cbnco.com>\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\n[ 2nd version ]\n\nOn Wed, Sep 19, 2007 at 12:44:18PM -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> > +To see how submodule support works, create (for example) four example\n> > +repository that can be used later as a submodule:\n> \n> s/repository/repositories/;\n\nfixed.\n\n> > +$ for i in a b c d\n> > +do\n> > +\tmkdir $i\n> > +\tcd $i\n> > +\tgit init\n> > +\techo \"module $i\" > $i.txt\n> > +\tgit add $i.txt\n> > +\tgit commit -m \"Initial commit, submodule $mod\"\n> \n> s/\\$mod/$i/;\n\nfixed\n\n> > +$ echo hi > super.txt\n> > +$ git add super.txt\n> > +$ git commit -m \"Initial commit of empty superproject\"\n> \n> This is not *empty*; do you even need this step?\n\nin fact, no :) removed.\n\n> > +-------------------------------------------------\n> > +$ git commit -m \"Add submodules a, b, c, d.\"\n> > +-------------------------------------------------\n> \n> s/c, d./c and d./;\n\nfixed.\n\n> > +$ ls -a a\n> > +.  ..\n> > +$ git submodule status\n> > +-d266b9873ad50488163457f025db7cdd9683d88b a\n> > +-e81d457da15309b4fef4249aba9b50187999670d b\n> > +-c1536a972b9affea0f16e0680ba87332dc059146 c\n> > +-d96249ff5d57de5de093e6baff9e0aafa5276a74 d\n> > +-------------------------------------------------\n> \n> You might want to mention...\n> \n>     Note: the commit object names shown above would be different for\n>     you, but they should match the HEAD commit object names of your\n>     repositories.  You can check it by doing:\n> \n>     $ git ls-remote ../a\n\ni've added such a note.\n\n> > +If you want to make a change within a submodule, you should first check out a\n> > +branch, make your changes, publish the change within the submodule, and then\n> > +update the superproject to reference the new commit:\n> > +\n> > +-------------------------------------------------\n> > +$ git branch\n> > +* (no branch)\n> > +  master\n> > +$ git checkout master\n> \n> I am not so sure about this advice.  Don't you want to see how\n> the detached HEAD and 'master' (or any other branches) are\n> related before doing this?  You might even want to create a\n> \"fix-up\" branch that is rooted at the detached HEAD if the\n> change you are making is to fix minor details of the submodule\n> to suit what superproject wants (i.e. \"little feature that is\n> applicable to the submodule as a standalone project, meant to\n> be pushed back to the submodule upstream\").\n\nright, changed it to two examples, one about \"git checkout master\", and\nthe other about \"git checkout -b fix-up\"\n\n> > +$ git push\n> > +$ cd ..\n> > +$ git add a\n> \n> Before doing this \"git add\", it would be educational to have the\n> user do\n> \n>     $ git diff\n> \n> which would say that now the submodule is being updated.\n\nadded.\n\n> > +$ git commit -m \"Updated submodule a.\"\n> > +$ git push\n> > +-------------------------------------------------\n> > +\n> > +NOTE: This means that you have to run `git submodule update` after `git pull`\n> > +if you want to update the subprojects, too.\n> \n> I do not quite understand this note.  I do understand the part\n> after \"that you have to\", but I do not know how the above\n> example relates to that --- iow, the above example does not\n> seem to \"mean\" such thing to me.\n> \n> Also \"submodule\" is used consistently in the rest of the\n> document but this sentence talks about \"subproject\".\n\nyes, it was illogical to use a 'note' here as it's not related. i've\njust added a separte sentence about this without the 'this means'.\n\n> > +Problems with submodules\n> > +------------------------\n> \n> The list is good, but are they Problems or pitfalls to watch out\n> for?\n\nthe later :) title changed.\n\n> > +Always publish the submodule change before publishing the change to the\n> > +superproject that references it. If you forget to publish the submodule change,\n> > +others won't be able to clone the repository:\n> \n> The same caution applies not to rewind branches in submodule\n> beyond commits that were ever recorded in any superproject.\n\ni've added a paragraph about this issue.\n\n> > +-------------------------------------------------\n> > +$ echo i added another line to this file >> a.txt\n> > +$ git commit -a -m \"doing it wrong this time\"\n> \n> It is not clear in which repository you are supposed to try this\n> command in the example sequence, as we crossed the section\n> boundary.  I am _guessing_ that the above two commands are to be\n> run inside ~/git/cloned-2/a after redoing ~/git/cloned-2 the\n> same way as you did ~/git/cloned, but you may want to make it\n> clear.\n\nright, i forgot the 'cd ~/git/super/a'. provided the repos are\nsymmetric, i think it would just make the situation unnecessary\ncomplicated to clone a third repo.\n\n> > +$ git submodule update\n> > +error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\n> > +Did you forget to 'git add'?\n> \n> I sense there is a bug in \"git submodule update\" here.  I do not\n> have time to look at what it's doing right now, but this is a\n> symptom of running:\n> \n>     $ git checkout 261dfac35...\n> \n> without checking if that is a valid commit object name, and git\n> checkout cannot decide if the request is about detaching the\n> head at commit 261dfac35 or checking the path 261dfac35 out of\n> the current index.  Porcelains should check with \"cat-file -t\"\n> first.\n\nhm yes. i think as long as this behaviour is not changed, it would not\nbe good to remove the \"Did you forget to 'git add'?\" part from the\nexample\n\n> > +Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'\n> > +-------------------------------------------------\n> > +\n> > +It's not safe to run `git submodule update` if you've made changes within a\n> > +submodule. They will be silently overwritten:\n> \n> You want to distinguish two cases here.  Local uncommitted\n> changes, and committed changes.  The latter case is switched\n> away without too much noise, which is what you are demonstrating\n> here.  I _think_ local uncommitted changes will not be\n> overwritten at all, unless \"submodule update\" does \"reset\n> --hard\", which I suspect it doesn't.\n\ni've just checked that it does a git checkout, so uncommitted changes\nare preserved. i've updated this part to mention this fact.\n\ni've also added the suggestions by skimo.\n\nVMiklos\n\n Documentation/user-manual.txt |  175 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 175 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex ecb2bf9..ce0cf38 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -3155,6 +3155,181 @@ a tree which you are in the process of working on.\n If you blow the index away entirely, you generally haven't lost any\n information as long as you have the name of the tree that it described.\n \n+[[submodules]]\n+Submodules\n+==========\n+\n+This tutorial explains how to create and publish a repository with submodules\n+using the gitlink:git-submodule[1] command.\n+\n+Submodules maintain their own identity; the submodule support just stores the\n+submodule repository location and commit ID, so other developers who clone the\n+superproject can easily clone all the submodules at the same revision.\n+\n+To see how submodule support works, create (for example) four example\n+repository that can be used later as a submodule:\n+\n+-------------------------------------------------\n+$ mkdir ~/git\n+$ cd ~/git\n+$ for i in a b c d\n+do\n+\tmkdir $i\n+\tcd $i\n+\tgit init\n+\techo \"module $i\" > $i.txt\n+\tgit add $i.txt\n+\tgit commit -m \"Initial commit, submodule $mod\"\n+\tcd ..\n+done\n+-------------------------------------------------\n+\n+Now create the superproject and add all the submodules:\n+\n+-------------------------------------------------\n+$ mkdir super\n+$ cd super\n+$ git init\n+$ echo hi > super.txt\n+$ git add super.txt\n+$ git commit -m \"Initial commit of empty superproject\"\n+$ for i in a b c d\n+do\n+\tgit submodule add ~/git/$i\n+done\n+-------------------------------------------------\n+\n+See what files `git submodule` created:\n+\n+-------------------------------------------------\n+$ ls -a\n+.  ..  .git  .gitmodules  a  b  c  d  super.txt\n+-------------------------------------------------\n+\n+The `git submodule add` command does a couple of things:\n+\n+- It clones the submodule under the current directory and by default checks out\n+  the master branch.\n+- It adds the submodule's clone path to the `.gitmodules` file and adds this\n+  file to the index, ready to be committed.\n+- It adds the submodule's current commit ID to the index, ready to be\n+  committed.\n+\n+Commit the superproject:\n+\n+-------------------------------------------------\n+$ git commit -m \"Add submodules a, b, c, d.\"\n+-------------------------------------------------\n+\n+Now clone the superproject:\n+\n+-------------------------------------------------\n+$ cd ..\n+$ git clone super cloned\n+$ cd cloned\n+-------------------------------------------------\n+\n+The submodule directories are there, but they're empty:\n+\n+-------------------------------------------------\n+$ ls -a a\n+.  ..\n+$ git submodule status\n+-d266b9873ad50488163457f025db7cdd9683d88b a\n+-e81d457da15309b4fef4249aba9b50187999670d b\n+-c1536a972b9affea0f16e0680ba87332dc059146 c\n+-d96249ff5d57de5de093e6baff9e0aafa5276a74 d\n+-------------------------------------------------\n+\n+Pulling down the submodules is a two-step process. First run `git submodule\n+init` to add the submodule repository URLs to `.git/config`:\n+\n+-------------------------------------------------\n+$ git submodule init\n+-------------------------------------------------\n+\n+Now use `git submodule update` to clone the repositories and check out the\n+commits specified in the superproject:\n+\n+-------------------------------------------------\n+$ git submodule update\n+$ cd a\n+$ ls -a\n+.  ..  .git  a.txt\n+-------------------------------------------------\n+\n+One major difference between `git submodule update` and `git submodule add` is\n+that `git submodule update` checks out a specific commit, rather than the tip\n+of a branch. It's like checking out a tag: the head is detached, so you're not\n+working on a branch.\n+\n+-------------------------------------------------\n+$ git branch\n+* (no branch)\n+  master\n+-------------------------------------------------\n+\n+If you want to make a change within a submodule, you should first check out a\n+branch, make your changes, publish the change within the submodule, and then\n+update the superproject to reference the new commit:\n+\n+-------------------------------------------------\n+$ git branch\n+* (no branch)\n+  master\n+$ git checkout master\n+$ echo \"adding a line again\" >> a.txt\n+$ git commit -a -m \"Updated the submodule from within the superproject.\"\n+$ git push\n+$ cd ..\n+$ git add a\n+$ git commit -m \"Updated submodule a.\"\n+$ git push\n+-------------------------------------------------\n+\n+NOTE: This means that you have to run `git submodule update` after `git pull`\n+if you want to update the subprojects, too.\n+\n+Problems with submodules\n+------------------------\n+\n+Always publish the submodule change before publishing the change to the\n+superproject that references it. If you forget to publish the submodule change,\n+others won't be able to clone the repository:\n+\n+-------------------------------------------------\n+$ echo i added another line to this file >> a.txt\n+$ git commit -a -m \"doing it wrong this time\"\n+$ cd ..\n+$ git add a\n+$ git commit -m \"Updated submodule a again.\"\n+$ git push\n+$ cd ~/git/cloned\n+$ git pull\n+$ git submodule update\n+error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\n+Did you forget to 'git add'?\n+Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'\n+-------------------------------------------------\n+\n+It's not safe to run `git submodule update` if you've made changes within a\n+submodule. They will be silently overwritten:\n+\n+-------------------------------------------------\n+$ cat a.txt\n+module a\n+$ echo line added from private2 >> a.txt\n+$ git commit -a -m \"line added inside private2\"\n+$ cd ..\n+$ git submodule update\n+Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b'\n+$ cd a\n+$ cat a.txt\n+module a\n+-------------------------------------------------\n+\n+NOTE: The changes are still visible in the submodule's reflog.\n+\n [[low-level-operations]]\n Low-level git operations\n ========================\n-- \n1.5.3.1.1.g1e61-dirty\n"},{"id":"53615","messageId":"20070920003413.GJ16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"7vbqbyphil.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] User Manual: add a chapter for submodules","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-20T00:34:14Z","receivedAt":"2007-09-20T00:34:14Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Michael Smith <msmith@cbnco.com>\nSigned-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nSorry, I sent the original patch again. So here is the updated second version.\n\n Documentation/user-manual.txt |  202 +++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 202 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/user-manual.txt b/Documentation/user-manual.txt\nindex ecb2bf9..aee654c 100644\n--- a/Documentation/user-manual.txt\n+++ b/Documentation/user-manual.txt\n@@ -3155,6 +3155,208 @@ a tree which you are in the process of working on.\n If you blow the index away entirely, you generally haven't lost any\n information as long as you have the name of the tree that it described.\n \n+[[submodules]]\n+Submodules\n+==========\n+\n+This tutorial explains how to create and publish a repository with submodules\n+using the gitlink:git-submodule[1] command.\n+\n+Submodules maintain their own identity; the submodule support just stores the\n+submodule repository location and commit ID, so other developers who clone the\n+superproject can easily clone all the submodules at the same revision.\n+\n+To see how submodule support works, create (for example) four example\n+repositories that can be used later as a submodule:\n+\n+-------------------------------------------------\n+$ mkdir ~/git\n+$ cd ~/git\n+$ for i in a b c d\n+do\n+\tmkdir $i\n+\tcd $i\n+\tgit init\n+\techo \"module $i\" > $i.txt\n+\tgit add $i.txt\n+\tgit commit -m \"Initial commit, submodule $i\"\n+\tcd ..\n+done\n+-------------------------------------------------\n+\n+Now create the superproject and add all the submodules:\n+\n+-------------------------------------------------\n+$ mkdir super\n+$ cd super\n+$ git init\n+$ for i in a b c d\n+do\n+\tgit submodule add ~/git/$i\n+done\n+-------------------------------------------------\n+\n+NOTE: Do not use local URLs here if you plan to publish your superproject!\n+\n+See what files `git submodule` created:\n+\n+-------------------------------------------------\n+$ ls -a\n+.  ..  .git  .gitmodules  a  b  c  d\n+-------------------------------------------------\n+\n+The `git submodule add` command does a couple of things:\n+\n+- It clones the submodule under the current directory and by default checks out\n+  the master branch.\n+- It adds the submodule's clone path to the `.gitmodules` file and adds this\n+  file to the index, ready to be committed.\n+- It adds the submodule's current commit ID to the index, ready to be\n+  committed.\n+\n+Commit the superproject:\n+\n+-------------------------------------------------\n+$ git commit -m \"Add submodules a, b, c and d.\"\n+-------------------------------------------------\n+\n+Now clone the superproject:\n+\n+-------------------------------------------------\n+$ cd ..\n+$ git clone super cloned\n+$ cd cloned\n+-------------------------------------------------\n+\n+The submodule directories are there, but they're empty:\n+\n+-------------------------------------------------\n+$ ls -a a\n+.  ..\n+$ git submodule status\n+-d266b9873ad50488163457f025db7cdd9683d88b a\n+-e81d457da15309b4fef4249aba9b50187999670d b\n+-c1536a972b9affea0f16e0680ba87332dc059146 c\n+-d96249ff5d57de5de093e6baff9e0aafa5276a74 d\n+-------------------------------------------------\n+\n+NOTE: The commit object names shown above would be different for you, but they\n+should match the HEAD commit object names of your repositories.  You can check\n+it by running `git ls-remote ../a`.\n+\n+Pulling down the submodules is a two-step process. First run `git submodule\n+init` to add the submodule repository URLs to `.git/config`:\n+\n+-------------------------------------------------\n+$ git submodule init\n+-------------------------------------------------\n+\n+Now use `git submodule update` to clone the repositories and check out the\n+commits specified in the superproject:\n+\n+-------------------------------------------------\n+$ git submodule update\n+$ cd a\n+$ ls -a\n+.  ..  .git  a.txt\n+-------------------------------------------------\n+\n+One major difference between `git submodule update` and `git submodule add` is\n+that `git submodule update` checks out a specific commit, rather than the tip\n+of a branch. It's like checking out a tag: the head is detached, so you're not\n+working on a branch.\n+\n+-------------------------------------------------\n+$ git branch\n+* (no branch)\n+  master\n+-------------------------------------------------\n+\n+If you want to make a change within a submodule and you have a detached head,\n+then you should create or checkout a branch, make your changes, publish the\n+change within the submodule, and then update the superproject to reference the\n+new commit:\n+\n+-------------------------------------------------\n+$ git checkout master\n+-------------------------------------------------\n+\n+or\n+\n+-------------------------------------------------\n+$ git checkout -b fix-up\n+-------------------------------------------------\n+\n+then\n+\n+-------------------------------------------------\n+$ echo \"adding a line again\" >> a.txt\n+$ git commit -a -m \"Updated the submodule from within the superproject.\"\n+$ git push\n+$ cd ..\n+$ git diff\n+diff --git a/a b/a\n+index d266b98..261dfac 160000\n+--- a/a\n++++ b/a\n+@@ -1 +1 @@\n+-Subproject commit d266b9873ad50488163457f025db7cdd9683d88b\n++Subproject commit 261dfac35cb99d380eb966e102c1197139f7fa24\n+$ git add a\n+$ git commit -m \"Updated submodule a.\"\n+$ git push\n+-------------------------------------------------\n+\n+You have to run `git submodule update` after `git pull` if you want to update\n+submodules, too.\n+\n+Pitfalls with submodules\n+------------------------\n+\n+Always publish the submodule change before publishing the change to the\n+superproject that references it. If you forget to publish the submodule change,\n+others won't be able to clone the repository:\n+\n+-------------------------------------------------\n+$ cd ~/git/super/a\n+$ echo i added another line to this file >> a.txt\n+$ git commit -a -m \"doing it wrong this time\"\n+$ cd ..\n+$ git add a\n+$ git commit -m \"Updated submodule a again.\"\n+$ git push\n+$ cd ~/git/cloned\n+$ git pull\n+$ git submodule update\n+error: pathspec '261dfac35cb99d380eb966e102c1197139f7fa24' did not match any file(s) known to git.\n+Did you forget to 'git add'?\n+Unable to checkout '261dfac35cb99d380eb966e102c1197139f7fa24' in submodule path 'a'\n+-------------------------------------------------\n+\n+You also should not rewind branches in a submodule beyond commits that were\n+ever recorded in any superproject.\n+\n+It's not safe to run `git submodule update` if you've made and committed\n+changes within a submodule without checking out a branch first. They will be\n+silently overwritten:\n+\n+-------------------------------------------------\n+$ cat a.txt\n+module a\n+$ echo line added from private2 >> a.txt\n+$ git commit -a -m \"line added inside private2\"\n+$ cd ..\n+$ git submodule update\n+Submodule path 'a': checked out 'd266b9873ad50488163457f025db7cdd9683d88b'\n+$ cd a\n+$ cat a.txt\n+module a\n+-------------------------------------------------\n+\n+NOTE: The changes are still visible in the submodule's reflog.\n+\n+This is not the case if you did not commit your changes.\n+\n [[low-level-operations]]\n Low-level git operations\n ========================\n-- \n1.5.3.1.1.g1e61-dirty\n"},{"id":"53622","messageId":"7v1wcum0ox.fsf@gitster.siamese.dyndns.org","threadId":"9922","inReplyTo":"20070920003413.GJ16235@genesis.frugalware.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-20T04:15:58Z","receivedAt":"2007-09-20T04:15:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> Signed-off-by: Michael Smith <msmith@cbnco.com>\n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n> ---\n>\n> Sorry, I sent the original patch again. So here is the updated second version.\n\nLooks Ok to me, although I didn't verify the examples by\nactually running them myself this time (last round I did).\n"},{"id":"53637","messageId":"Pine.LNX.4.64.0709201133590.28395@racer.site","threadId":"9922","inReplyTo":"7v1wcum0ox.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-20T10:34:25Z","receivedAt":"2007-09-20T10:34:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 19 Sep 2007, Junio C Hamano wrote:\n\n> Miklos Vajna <vmiklos@frugalware.org> writes:\n> \n> > Signed-off-by: Michael Smith <msmith@cbnco.com>\n> > Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n> > ---\n> >\n> > Sorry, I sent the original patch again. So here is the updated second version.\n> \n> Looks Ok to me, although I didn't verify the examples by\n> actually running them myself this time (last round I did).\n\nSo maybe we should do the same as with the tutorial: stick the examples \ninto a test script?\n\nCiao,\nDscho\n"},{"id":"53661","messageId":"20070920170831.GQ16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"Pine.LNX.4.64.0709201133590.28395@racer.site","subject":"[PATCH] new test from the submodule chapter of the user manual","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-20T17:08:31Z","receivedAt":"2007-09-20T17:08:31Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nOn Thu, Sep 20, 2007 at 11:34:25AM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> On Wed, 19 Sep 2007, Junio C Hamano wrote:\n> > Looks Ok to me, although I didn't verify the examples by\n> > actually running them myself this time (last round I did).\n>\n> So maybe we should do the same as with the tutorial: stick the examples\n> into a test script?\n\nwhat about this?\n\n t/t3060-subprojects-tutorial.sh |   62 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 62 insertions(+), 0 deletions(-)\n create mode 100755 t/t3060-subprojects-tutorial.sh\n\ndiff --git a/t/t3060-subprojects-tutorial.sh b/t/t3060-subprojects-tutorial.sh\nnew file mode 100755\nindex 0000000..2fcf4ab\n--- /dev/null\n+++ b/t/t3060-subprojects-tutorial.sh\n@@ -0,0 +1,62 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Miklos Vajna\n+#\n+\n+test_description='A simple subprojects tutorial in the form of a test case'\n+\n+. ./test-lib.sh\n+\n+test_expect_success \"create the submodules\" '\n+\tfor i in a b c d\n+\tdo\n+\t\tmkdir $i &&\n+\t\tcd $i &&\n+\t\tgit init &&\n+\t\techo \"module $i\" > $i.txt &&\n+\t\tgit add $i.txt &&\n+\t\tgit commit -m \"Initial commit, submodule $i\" &&\n+\t\tcd ..\n+\tdone\n+'\n+\n+test_expect_success \"create the superproject\" '\n+\tmkdir super &&\n+\tcd super &&\n+\tgit init &&\n+\tfor i in a b c d\n+\tdo\n+\t\tgit submodule add '`pwd`'/$i\n+\tdone\n+'\n+\n+test_expect_success \"commit in the superproject\" '\n+\tgit commit -m \"Add submodules a, b, c and d.\" &&\n+\tcd ..\n+'\n+\n+test_expect_success \"clone the superproject\" '\n+\tgit clone super cloned &&\n+\tcd cloned\n+'\n+\n+test_expect_success \"submodule init\" '\n+\tgit submodule init\n+'\n+\n+test_expect_success \"submodule update\" '\n+\tgit submodule update\n+'\n+\n+test_expect_success \"update the submodule from within the superproject\" '\n+\tcd a &&\n+\techo \"adding a line again\" >> a.txt &&\n+\tgit commit -a -m \"Updated the submodule from within the superproject.\" &&\n+\tgit push &&\n+\tcd .. &&\n+\tgit add a &&\n+\tgit commit -m \"Updated submodule a.\" &&\n+\tgit push\n+'\n+\n+test_done\n-- \n1.5.3.2.80.g077d6f-dirty\n"},{"id":"53663","messageId":"20070920175952.GC30391@tasint.org","threadId":"9922","inReplyTo":"20070920170831.GQ16235@genesis.frugalware.org","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Joel Becker","fromEmail":"joel.becker@oracle.com","sentAt":"2007-09-20T17:59:52Z","receivedAt":"2007-09-20T17:59:52Z","isPatch":true,"sender":{"key":"joel.becker@oracle.com","avatar":null},"body":"On Thu, Sep 20, 2007 at 07:08:31PM +0200, Miklos Vajna wrote:\n> +test_expect_success \"create the submodules\" '\n> +\tfor i in a b c d\n> +\tdo\n> +\t\tmkdir $i &&\n> +\t\tcd $i &&\n> +\t\tgit init &&\n> +\t\techo \"module $i\" > $i.txt &&\n> +\t\tgit add $i.txt &&\n> +\t\tgit commit -m \"Initial commit, submodule $i\" &&\n> +\t\tcd ..\n> +\tdone\n\n\tSilly question: why use the '&&' when you can 'set -e'?  As it\ncurrently stands, a failure will still go back around the loop...\n\nJoel\n\n-- \n\n\"Sometimes when reading Goethe I have the paralyzing suspicion\n that he is trying to be funny.\"\n         - Guy Davenport\n\nJoel Becker\nPrincipal Software Developer\nOracle\nE-mail: joel.becker@oracle.com\nPhone: (650) 506-8127\n"},{"id":"53666","messageId":"Pine.LNX.4.64.0709201946410.28395@racer.site","threadId":"9922","inReplyTo":"20070920175952.GC30391@tasint.org","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-09-20T18:47:32Z","receivedAt":"2007-09-20T18:47:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 20 Sep 2007, Joel Becker wrote:\n\n> On Thu, Sep 20, 2007 at 07:08:31PM +0200, Miklos Vajna wrote:\n> > +test_expect_success \"create the submodules\" '\n> > +\tfor i in a b c d\n> > +\tdo\n> > +\t\tmkdir $i &&\n> > +\t\tcd $i &&\n> > +\t\tgit init &&\n> > +\t\techo \"module $i\" > $i.txt &&\n> > +\t\tgit add $i.txt &&\n> > +\t\tgit commit -m \"Initial commit, submodule $i\" &&\n> > +\t\tcd ..\n> > +\tdone\n> \n> \tSilly question: why use the '&&' when you can 'set -e'?  As it\n> currently stands, a failure will still go back around the loop...\n\nA \"set -e\" will make the script exit AFAIR.  That's not what we want.  A \nsimple \"|| break\" after the \"cd ..\" will work, though.\n\nCiao,\nDscho\n"},{"id":"53676","messageId":"7vd4wdkokn.fsf@gitster.siamese.dyndns.org","threadId":"9922","inReplyTo":"20070920170831.GQ16235@genesis.frugalware.org","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-20T21:35:20Z","receivedAt":"2007-09-20T21:35:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miklos Vajna <vmiklos@frugalware.org> writes:\n\n> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n> ---\n>\n> On Thu, Sep 20, 2007 at 11:34:25AM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>> On Wed, 19 Sep 2007, Junio C Hamano wrote:\n>> > Looks Ok to me, although I didn't verify the examples by\n>> > actually running them myself this time (last round I did).\n>>\n>> So maybe we should do the same as with the tutorial: stick the examples\n>> into a test script?\n>\n> what about this?\n\nFar too inadequate.  You test if \"commit\" reports success, but\ndo not check if what is committed is what you wanted to commit,\nfor example.\n"},{"id":"53679","messageId":"20070920214609.GT16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"Pine.LNX.4.64.0709201946410.28395@racer.site","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-20T21:46:09Z","receivedAt":"2007-09-20T21:46:09Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Thu, Sep 20, 2007 at 07:47:32PM +0100, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > +test_expect_success \"create the submodules\" '\n> > > +\tfor i in a b c d\n> > > +\tdo\n> > > +\t\tmkdir $i &&\n> > > +\t\tcd $i &&\n> > > +\t\tgit init &&\n> > > +\t\techo \"module $i\" > $i.txt &&\n> > > +\t\tgit add $i.txt &&\n> > > +\t\tgit commit -m \"Initial commit, submodule $i\" &&\n> > > +\t\tcd ..\n> > > +\tdone\n> > \n> > \tSilly question: why use the '&&' when you can 'set -e'?  As it\n> > currently stands, a failure will still go back around the loop...\n> \n> A \"set -e\" will make the script exit AFAIR.  That's not what we want.  A \n> simple \"|| break\" after the \"cd ..\" will work, though.\n\ni know i asked this on irc, but i still a bit confused. the target would\nbe to jump out from the loop and return 'false' if any of the items\nfails\n\nif i understand correctly then this is what Dscho proposes:\n\n$ for i in a b; do echo $i && false || break; done\na\n$ echo $?\n0\n\nthis jumps out from the loop but does not return false\n\nhere is my version:\n\n$ for i in a b; do echo $i && false; done\na\nb\n\n$ echo $?\n1\n\nthis one detects the error but does not jump out from the loop. none of\nthem is perfect, but at least my version fails as long as the last cycle\nfails (which is not problem as i think in most cases all or none of the\ncycles will fail)\n\nanyway, if you really want, i can change it, but i think it is not the\nright thing to do\n\n- VMiklos\n"},{"id":"53683","messageId":"20070920220204.GU16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"7v1wcum0ox.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] User Manual: add a chapter for submodules","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-20T22:02:04Z","receivedAt":"2007-09-20T22:02:04Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Wed, Sep 19, 2007 at 09:15:58PM -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> Looks Ok to me, although I didn't verify the examples by\n> actually running them myself this time (last round I did).\n\njust wanted to mention that i did verify them before sending the patch.\n\n- VMiklos\n"},{"id":"53686","messageId":"20070920225646.GB3490@tasint.org","threadId":"9922","inReplyTo":"Pine.LNX.4.64.0709201946410.28395@racer.site","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Joel Becker","fromEmail":"joel.becker@oracle.com","sentAt":"2007-09-20T22:56:46Z","receivedAt":"2007-09-20T22:56:46Z","isPatch":true,"sender":{"key":"joel.becker@oracle.com","avatar":null},"body":"On Thu, Sep 20, 2007 at 07:47:32PM +0100, Johannes Schindelin wrote:\n> > \tSilly question: why use the '&&' when you can 'set -e'?  As it\n> > currently stands, a failure will still go back around the loop...\n> \n> A \"set -e\" will make the script exit AFAIR.  That's not what we want.  A \n> simple \"|| break\" after the \"cd ..\" will work, though.\n\n\tOh, drat.  It's run in eval, not a subshell.\n\nJoel\n\n-- \n\nLife's Little Instruction Book #94\n\n\t\"Make it a habit to do nice things for people who \n\t will never find out.\"\n\nJoel Becker\nPrincipal Software Developer\nOracle\nE-mail: joel.becker@oracle.com\nPhone: (650) 506-8127\n"},{"id":"53722","messageId":"20070921130908.GF16235@genesis.frugalware.org","threadId":"9922","inReplyTo":"7vd4wdkokn.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] new test from the submodule chapter of the user manual","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-21T13:09:08Z","receivedAt":"2007-09-21T13:09:08Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nsecond version, now checking for all output, the commit hashes shows what is\ncommitted is what we wanted to commit.\n\n t/t3060-subprojects-tutorial.sh |  151 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 151 insertions(+), 0 deletions(-)\n create mode 100755 t/t3060-subprojects-tutorial.sh\n\ndiff --git a/t/t3060-subprojects-tutorial.sh b/t/t3060-subprojects-tutorial.sh\nnew file mode 100755\nindex 0000000..fc09451\n--- /dev/null\n+++ b/t/t3060-subprojects-tutorial.sh\n@@ -0,0 +1,151 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Miklos Vajna\n+#\n+\n+test_description='A simple subprojects tutorial in the form of a test case'\n+\n+. ./test-lib.sh\n+\n+test_tick\n+\n+cat > create.expect << EOF\n+Initialized empty Git repository in .git/\n+Created initial commit 85349d2: Initial commit, submodule a\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+ create mode 100644 a.txt\n+Initialized empty Git repository in .git/\n+Created initial commit 47398d6: Initial commit, submodule b\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+ create mode 100644 b.txt\n+Initialized empty Git repository in .git/\n+Created initial commit 3d88526: Initial commit, submodule c\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+ create mode 100644 c.txt\n+Initialized empty Git repository in .git/\n+Created initial commit 73af3de: Initial commit, submodule d\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+ create mode 100644 d.txt\n+EOF\n+\n+for i in a b c d\n+do\n+\tmkdir $i &&\n+\tcd $i &&\n+\tgit init &&\n+\techo \"module $i\" > $i.txt &&\n+\tgit add $i.txt &&\n+\tgit commit -m \"Initial commit, submodule $i\" &&\n+\tcd ..\n+done > create.output\n+test_expect_success \"create the submodules\" 'cmp create.expect create.output'\n+\n+mkdir super\n+cd super\n+cat > create-super.expect << EOF\n+Initialized empty Git repository in .git/\n+Initialized empty Git repository in `pwd`/a/.git/\n+0 blocks\n+Initialized empty Git repository in `pwd`/b/.git/\n+0 blocks\n+Initialized empty Git repository in `pwd`/c/.git/\n+0 blocks\n+Initialized empty Git repository in `pwd`/d/.git/\n+0 blocks\n+EOF\n+\n+(git init &&\n+for i in a b c d\n+do\n+\tgit submodule add `pwd`/../$i\n+done ) &> create-super.output\n+test_expect_success \"create the superproject\" 'cmp create-super.expect create-super.output'\n+\n+cat > commit-superproject.expect << EOF\n+Created initial commit c496be9: Add submodules a, b, c and d.\n+ 5 files changed, 16 insertions(+), 0 deletions(-)\n+ create mode 100644 .gitmodules\n+ create mode 160000 a\n+ create mode 160000 b\n+ create mode 160000 c\n+ create mode 160000 d\n+EOF\n+git commit -m \"Add submodules a, b, c and d.\" > commit-superproject.output\n+\n+test_expect_success \"commit in the superproject\" 'cmp commit-superproject.expect commit-superproject.output'\n+\n+cd ..\n+\n+cat > clone.expect << EOF\n+Initialized empty Git repository in `pwd`/cloned/.git/\n+0 blocks\n+EOF\n+\n+git clone super cloned &> clone.output\n+\n+test_expect_success \"clone the superproject\" 'cmp clone.expect clone.output'\n+\n+cd cloned\n+\n+cat > submodule-init.expect << EOF\n+Submodule 'a' (${PWD%%/cloned}/a/.git) registered for path 'a'\n+Submodule 'b' (${PWD%%/cloned}/b/.git) registered for path 'b'\n+Submodule 'c' (${PWD%%/cloned}/c/.git) registered for path 'c'\n+Submodule 'd' (${PWD%%/cloned}/d/.git) registered for path 'd'\n+EOF\n+\n+git submodule init > submodule-init.output\n+\n+test_expect_success \"submodule init\" 'cmp submodule-init.expect submodule-init.output'\n+\n+cat > submodule-update.expect << EOF\n+Initialized empty Git repository in `pwd`/a/.git/\n+0 blocks\n+Submodule path 'a': checked out '85349d24595f581f5548b321a55c8a5fbe87259f'\n+Initialized empty Git repository in `pwd`/b/.git/\n+0 blocks\n+Submodule path 'b': checked out '47398d6286153d23bfd5780ae3bf1996eb18cf90'\n+Initialized empty Git repository in `pwd`/c/.git/\n+0 blocks\n+Submodule path 'c': checked out '3d88526ff6973dd27a07f57a3bb2bf5fa0bada42'\n+Initialized empty Git repository in `pwd`/d/.git/\n+0 blocks\n+Submodule path 'd': checked out '73af3de6718291404ef541f4bb152f87d35a1481'\n+EOF\n+\n+git submodule update &> submodule-update.output\n+\n+test_expect_success \"submodule update\" 'cmp submodule-update.expect submodule-update.output'\n+\n+cat > submodule-push.expect << EOF\n+Created commit ab78b5a: Updated the submodule from within the superproject.\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+Everything up-to-date\n+Created commit 8bbfffe: Updated submodule a.\n+ 1 files changed, 1 insertions(+), 1 deletions(-)\n+updating 'refs/heads/master'\n+  from c496be9e726d5c6ee0f96668b1b5822cf6cad027\n+  to   8bbfffe1651b896e371bf7a3506452d545cf81b3\n+ Also local refs/remotes/origin/master\n+Generating pack...\n+Done counting 2 objects.\n+Deltifying 2 objects...\n+  50% (1/2) done\n 100% (2/2) done\n\n+Writing 2 objects...\n+  50% (1/2) done\n 100% (2/2) done\n\n+Total 2 (delta 0), reused 0 (delta 0)\n+refs/heads/master: c496be9e726d5c6ee0f96668b1b5822cf6cad027 -> 8bbfffe1651b896e371bf7a3506452d545cf81b3\n+EOF\n+\n+( cd a &&\n+echo \"adding a line again\" >> a.txt &&\n+git commit -a -m \"Updated the submodule from within the superproject.\" &&\n+git push &&\n+cd .. &&\n+git add a &&\n+git commit -m \"Updated submodule a.\" &&\n+git push) &> submodule-push.output\n+\n+test_expect_success \"update the submodule from within the superproject\" 'cmp submodule-push.expect submodule-push.output'\n+\n+test_done\n-- \n1.5.3.2.80.g077d6f-dirty\n"},{"id":"53736","messageId":"7v1wcrki96.fsf@gitster.siamese.dyndns.org","threadId":"9922","inReplyTo":"20070921130908.GF16235@genesis.frugalware.org","subject":"Re: [PATCH] new test from the submodule chapter of the user manual","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-09-21T18:04:05Z","receivedAt":"2007-09-21T18:04:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"That's horrible.  Please do not depend on object SHA1's to stay\nthe same.  If somebody makes a fix to the test to add a new file\nin a sample subproject it would break all the rest.  Also please\ndo not depend on the progress output.\n\nIn short, please do not try to get away with quick-and-dirty.\n"},{"id":"53811","messageId":"20070922200535.GE24023@genesis.frugalware.org","threadId":"9922","inReplyTo":"7v1wcrki96.fsf@gitster.siamese.dyndns.org","subject":"[PATCH] new test from the submodule chapter of the user manual","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-22T20:05:35Z","receivedAt":"2007-09-22T20:05:35Z","isPatch":true,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>\n---\n\nOn Fri, Sep 21, 2007 at 11:04:05AM -0700, Junio C Hamano <gitster@pobox.com> wrote:\n> That's horrible.  Please do not depend on object SHA1's to stay\n> the same.  If somebody makes a fix to the test to add a new file\n> in a sample subproject it would break all the rest.  Also please\n> do not depend on the progress output.\n\nokay, here is the third try. now checking for the result using diff-tree and\nls-files. hopefully i did what you expected :)\n\n t/t3060-subprojects-tutorial.sh |   95 +++++++++++++++++++++++++++++++++++++++\n 1 files changed, 95 insertions(+), 0 deletions(-)\n create mode 100755 t/t3060-subprojects-tutorial.sh\n\ndiff --git a/t/t3060-subprojects-tutorial.sh b/t/t3060-subprojects-tutorial.sh\nnew file mode 100755\nindex 0000000..d46dded\n--- /dev/null\n+++ b/t/t3060-subprojects-tutorial.sh\n@@ -0,0 +1,95 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Miklos Vajna\n+#\n+\n+test_description='A simple subprojects tutorial in the form of a test case'\n+\n+. ./test-lib.sh\n+\n+test_expect_success \"create the submodules\" '\n+\tfor i in a b c d\n+\tdo\n+\t\tmkdir $i &&\n+\t\tcd $i &&\n+\t\tgit init &&\n+\t\techo \"module $i\" > $i.txt &&\n+\t\tgit add $i.txt &&\n+\t\tgit commit -m \"Initial commit, submodule $i\" &&\n+\t\tcd ..\n+\tdone\n+'\n+\n+mkdir super\n+cd super\n+cat >expected << EOF\n+:000000 100644 00000... A\t.gitmodules\n+:000000 160000 00000... A\ta\n+:000000 160000 00000... A\tb\n+:000000 160000 00000... A\tc\n+:000000 160000 00000... A\td\n+EOF\n+\n+test_expect_success \"create the superproject\" '\n+\tgit init &&\n+\techo super > super.txt &&\n+\tgit add super.txt &&\n+\tgit commit -m \"initial\" &&\n+\tfor i in a b c d\n+\tdo\n+\t\tgit submodule add '`pwd`'/../$i\n+\tdone &&\n+\tgit commit -m \"Add submodules a, b, c and d.\" &&\n+\tgit diff-tree --abbrev=5 HEAD^ HEAD |cut -d\" \" -f-3,5- >current &&\n+\tcmp expected current\n+'\n+\n+test_expect_success \"checking if the correct commit is stored in the superproject\" '\n+\tfor i in a b c d\n+\tdo\n+\t\tgit ls-files -s $i|cut -d \" \" -f 2 > $i.actual &&\n+\t\t(cd $i && git-rev-parse HEAD) > $i.expected &&\n+\t\tcmp $i.actual $i.expected\n+\tdone &&\n+\tcd ..\n+'\n+\n+test_expect_success \"clone the superproject\" '\n+\tgit clone super cloned &&\n+\tcd cloned\n+'\n+\n+test_expect_success \"submodule init\" '\n+\tgit submodule init\n+'\n+\n+test_expect_success \"submodule update\" '\n+\tgit submodule update\n+'\n+\n+test_expect_success \"checking the result of the commit in the cloned project\" '\n+\tfor i in a b c d\n+\tdo\n+\t\tgit ls-files -s $i|cut -d \" \" -f 2 > $i.actual &&\n+\t\t(cd $i && git-rev-parse HEAD) > $i.expected &&\n+\t\tcmp $i.actual $i.expected\n+\tdone\n+'\n+\n+test_expect_success \"update the submodule from within the superproject\" '\n+\tcd a &&\n+\techo \"adding a line again\" >> a.txt &&\n+\tgit commit -a -m \"Updated the submodule from within the superproject.\" &&\n+\tgit push &&\n+\tcd .. &&\n+\tgit add a &&\n+\tgit commit -m \"Updated submodule a.\" &&\n+\tgit push\n+'\n+\n+test_expect_success \"checking the result of the commit in the updated cloned project\" '\n+\tgit ls-files -s a|cut -d \" \" -f 2 > a.actual &&\n+\t(cd a && git-rev-parse HEAD) > a.expected &&\n+\tcmp a.actual a.expected\n+'\n+test_done\n-- \n1.5.3.2.80.g077d6f-dirty\n"},{"id":"53894","messageId":"20070924071135.GB3278@informatik.uni-freiburg.de","threadId":"9922","inReplyTo":"20070918105538.GL19019@genesis.frugalware.org","subject":"Re: [rfc] git submodules howto","fromName":"Uwe Kleine-König","fromEmail":"ukleinek@informatik.uni-freiburg.de","sentAt":"2007-09-24T07:11:35Z","receivedAt":"2007-09-24T07:11:35Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nMiklos Vajna wrote:\n> $ mkdir lib\n> $ cd lib\n> $ git init\n> Initialized empty Git repository in .git/\n> $ echo \"libmakefile\" > Makefile\n> $ dg add Makefile\n>\n> [...]\n>\n> 1) is this correct? :) i use it and it seem to do what i except, but\n> maybe it's not correct\n\nI get \n\n\tbash: dg: command not found\n\n:-)  Probably s/dg/git/\n\nBest regards\nUwe\n\n-- \nUwe Kleine-König\n\nhttp://www.google.com/search?q=half+a+cup+in+teaspoons\n"},{"id":"53899","messageId":"20070924083025.GJ24023@genesis.frugalware.org","threadId":"9922","inReplyTo":"20070924071135.GB3278@informatik.uni-freiburg.de","subject":"Re: [rfc] git submodules howto","fromName":"Miklos Vajna","fromEmail":"vmiklos@frugalware.org","sentAt":"2007-09-24T08:30:25Z","receivedAt":"2007-09-24T08:30:25Z","isPatch":false,"sender":{"key":"vmiklos@frugalware.org","avatar":"https://gravatar.com/avatar/401c1cbbb3a5d13e650c691a2c71d6fd0b80df1a01bc74d9f1972675dd58f2bd?d=mp&s=160"},"body":"On Mon, Sep 24, 2007 at 09:11:35AM +0200, Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de> wrote:\n> I get \n> \n> \tbash: dg: command not found\n> \n> :-)  Probably s/dg/git/\n\nyes, thanks for the correction\n\n- VMiklos\n"}]}