git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Possible submodule or submodule documentation issue

From
Jens Lehmann <jens.lehmann@web.de>
Date
Dec 28, 2011, 19:47 UTC
Message-ID
<4EFB725C.7030600@web.de>
In-Reply-To
<1325013859.1987.65.camel@yos>
Am 27.12.2011 20:24, schrieb Bill Zaumen:
Show 28 quoted lines
> For the 'add' command, the man page for get-submodule states
> 
> "<repository> is the URL of the new submodule’s origin repository. This
> may be either an absolute URL, or (if it begins with ./ or ../), the
> location relative to the superproject’s origin repository."
> 
> and
> 
> "In either case, the given URL is recorded into .gitmodules for use by
> subsequent users cloning the superproject. If the URL is given relative
> to the superproject’s repository, the presumption is the superproject
> and submodule repositories will be kept together in the same relative
> location, and only the superproject’s URL needs to be provided:
> git-submodule will correctly locate the submodule using the relative URL
> in .gitmodules."
> 
> Based on that documentation, I tried the following sequence of commands:
> 
> git init --bare library.git
> git init --bare library-pkg.git
> git clone library.git
> cd library;
> echo hello > hello
> git add hello
> git commit -m "initial"
> git push origin master
> cd ..
> git clone library-pkg.git
I assume you did forget to add a "cd library-pkg" here.
> echo goodbye > goodbye
> git add goodbye
> git submodule add ./library.git src   <FAILS>
With Git 1.7.1 I get the following error message:

fatal: '/tmp/library-pkg.git/library.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly Clone of '/tmp/library-pkg.git/library.git' into submodule path 'src' failed

Which is rather what I would have expected: Using "./library.git src" implies the library living *inside* the "library-pkg.git" repo, not next to it (and the error message shows that). "../library.git" is the correct relative path, so the next command works as expected.

Show 10 quoted lines
> git submodule add ../library.git src  <WORKS>
> git commit -a -m "initial pkg"
> git push origin master
> 
> The documentation as written suggests that the first use of 
> "git submodule add" is the one that should have worked because
> library.git is in the same directory as the origin repository
> library-pgk.git .  I didn't try moving the two .git directories
> to a server to see if the behavior is the same in that case (my
> test was using the local file system).

Hmm, the documentation says "the location relative to the superproject’s origin repository", not the directory containing it. This means you have to use ".." first to get out of the repository itself, no?

Previous: Bill ZaumenNext: Bill Zaumen
Message 2 of 6 in “Possible submodule or submodule documentation issue”
  1. Bill ZaumenDec 27, 2011
  2. Jens LehmannDec 28, 2011
  3. Bill ZaumenDec 29, 2011
  4. Jens LehmannJan 1, 2012
  5. Bill ZaumenJan 2, 2012
  6. Junio C HamanoJan 3, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.