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

Re: git submodule add --single-branch

From
Stefan Beller <sbeller@google.com>
Date
Feb 25, 2016, 19:05 UTC
Message-ID
<CAGZ79ka-SAiBC0EHKkESvapS1dvxADOrBvq5ik1r61jjb=jepg@mail.gmail.com>
In-Reply-To
<8e46e2f93895fb33421e7b09ccfe7de5@www.hilie.de>
On Thu, Feb 25, 2016 at 9:54 AM, Alter Depp <Alter.Depp@gmx.de> wrote:
Show 9 quoted lines
> I would like to do a shallow clone of a submodule like this:
> $ git submodule add --branch master --single-branch --depth 5 repo dir
> but it doesn't work. I think '--single-branch' is not yet implemented for
> submodules.
>
> With the clone command it works:
> $ git clone --branch master --single-branch --depth 5 repo dir
>
> Is it possible to do something like this with a submodule?

Shallow submodules are not quite well supported. Example:

    $ git clone --depth 2 --recurse-submodules <url>

the depth argument applies to the main repository, and currently it is passed on to the submodules if any.

The '--depth 2' suggests that you can operate on the 2 topmost revisions of the super project flawlessly, so if the submodule pointer in the superproject is advanced more than 2 commits between these 2 commits, you're missing content.

So in this case you don't want to pass on the depth literally to the submodule, but rather find out which commits are referenced from the superproject and make sure those are included in the submodule.

In your case of adding a submodule as a shallow repo, this problem is not there. However 'git sub add' will eventually call 'git clone' to get that submodule and '--single-branch' is implied by the existance of the '--depth' argument there. See the man page of git clone for that.

So 'git submodule add --depth 5 <url>' should do what you'd expect. Unfortunately you cannot specify '--branch=master' though yet.

Stefan
Show 8 quoted lines
>
> Stefan
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous: Alter Depp
Message 2 of 2 in “git submodule add --single-branch”
  1. Alter DeppFeb 25, 2016
  2. Stefan BellerFeb 25, 2016

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.