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

Re: git clone combined with --depth, --branch and --single-branch

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 17, 2013, 14:32 UTC
Message-ID
<CACsJy8C5G7yy=KDtdsE-9aYTdSEO3v=-25WKtGnLALshXnE+uQ@mail.gmail.com>
In-Reply-To
<CAByu6UWNZLrtwo+FUeq2OELoX3jo1Qng9amko36JGa5pq+y11A@mail.gmail.com>

On Sun, Feb 17, 2013 at 7:29 PM, Thibault Kruse <tibokruse@googlemail.com> wrote:

Show 17 quoted lines
> git log --pretty=format:'%h-%s %d' --graph --decorate  --all
> * 4565162-5  (foo)
> * 20ce846-4
> * a0615eb-3
> * fa4131d-2
> * f0683bd-1  (bar)
> | * 432b5ec-m1  (HEAD, master)
> |/
> * 39df203-0
>
> git clone repo1 repo2 --depth 1
> cd repo2
> git log --pretty=format:'%h-%s %d' --graph --decorate  --all
> * 432b5ec-m1  (HEAD, origin/master, origin/HEAD, master)
> * 39df203-0
>
> # Why are branches "foo" and "bar" missing?

--depth implies --single-branch. Without explicit --branch, --single-branch will fetch HEAD. You need --no-single-branch to get foo and bar.

Show 14 quoted lines
> cd ..
> git clone repo1 repo3 --depth 1 --branch foo
> git log --pretty=format:'%h-%s %d' --graph --decorate  --all
> * 4565162-5  (HEAD, origin/foo, foo)
> * 20ce846-4
> * a0615eb-3
> * fa4131d-2
> * f0683bd-1
> | * 432b5ec-m1  (origin/master, origin/HEAD)
> |/
> * 39df203-0
>
> # Why is --depth not having effect, and why is branch bar not there,
> yet master is?

I'm not sure, but I can't reproduce it. There's an unreleased fix in depth calculation (682c7d2 (upload-pack: fix off-by-one depth calculation in shallow clone - 2013-01-11) that might affect this. You may want to try again with "master". I got this with the same command

* edbd6cb (grafted, HEAD, origin/foo, foo) 5
-- 
Duy
Previous: Thibault KruseNext: Thibault Kruse
Message 2 of 4 in “git clone combined with --depth, --branch and --single-branch”
  1. Thibault KruseFeb 17, 2013
  2. Duy NguyenFeb 17, 2013
  3. Thibault KruseFeb 17, 2013
  4. Fwd: git clone combined with --depth, --branch and --single-branchThibault Kruse, Feb 17, 2013

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.