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

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

From
Thibault Kruse <tibokruse@googlemail.com>
Date
Feb 17, 2013, 17:46 UTC
Message-ID
<CAByu6UWw-6ssEug-Fm1t7_L2jVuC-KMh-NC=kzxfum=r6X5VcQ@mail.gmail.com>
In-Reply-To
<CACsJy8C5G7yy=KDtdsE-9aYTdSEO3v=-25WKtGnLALshXnE+uQ@mail.gmail.com>
Hi Duy,
On Sun, Feb 17, 2013 at 3:32 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 23 quoted lines
> On Sun, Feb 17, 2013 at 7:29 PM, Thibault Kruse
> <tibokruse@googlemail.com> wrote:
>> 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.

Agreed, sorry. I forgot that --depth implied --single-branch. Probably because it don't like that being a default that breaks behavior to versions that did not have the --single-branch feature. So this example is the only one which I agree does actually what can be expected from the documentation (with respect to branches. --depth also does not restrict the history length, but the example does not show it).

Show 16 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.
Do you mean you cannot reproduce with 1.7.10.4?
So far I used ubuntu packaged versions, Here is what I got with master:
git --version
git version 1.8.1.3.619.g7b6e784
# added commit m2 and m3 to master branch in repo1 to show that
--depth is not working locally
git clone repo1 repo2 --depth 1
git log --pretty=format:'%h-%s %d' --graph --decorate  --all
* 704f0c4-m3  (HEAD, origin/master, origin/HEAD, master)
* 7b90b28-m2
* 1fa92bd-m1
* 5da3517-0

So I still get the --depth not having affect locally, but I confirm all other cases I posted work as expected with 1.8.1.3.619.g7b6e784. Meaning --depth works from a remote repo, and --single-branch (implied by depth) really just creates that branch locally.

I don't even know where to start looking for why --depth has no effect for disk-local remotes. I don't have the git command aliased, and in repo1, I get: alias.br=branch alias.co=checkout alias.ci=commit alias.di=diff alias.st=status alias.mt=mergetool alias.pr=pull --rebase alias.ri=rebase --interactive alias.sa=stash apply alias.c-p=cherry-pick alias.lg=!git log --pretty=format:%h%x09%an%x09%ad%x09%s alias.lgg=log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative alias.top=!eval cd $(pwd)/$(git rev-parse --show-cdup) && pwd core.excludesfile=/home/kruset/.bashconfig/gitignore.global core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true

Not sure whether any of the "core" properties can cause this.
Previous: Duy NguyenNext: Thibault Kruse
Message 3 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.