git clone combined with --depth, --branch and --single-branch
Hi all, Using git 1.7.10.4 I find the behavior or documentation of git clone --single-branch confusing. Docs currently say: man git-clone --single-branch Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote�8099s HEAD points at. When creating a shallow clone with the --depth option, this is the default, unless --no-single-branch is given to fetch the histories near the tips of all branches. based onthis documentation, I cannot understand any of the results I get when combining --depth and --singe-branch. I start with this repo1 (for how to createin linux, see bottom): 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? 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? cd .. git clone repo1 repo4 --depth 1 --branch foo --single-branch 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 master still there? ### # Okay, so --depth seems to generally not work when cloning locally. So maybe when doing so from github: git clone https://github.com/git/git --depth 1 cd git git log --pretty=format:'%h-%s %d' --graph --decorate --all * 7b6e784-Update draft release notes to 1.8.2 (HEAD, origin/master, origin/HEAD, master) * 17e45f8-Merge branch 'wk/man-deny-current-branch-is-default-these-days' (grafted) git branch -a * master remotes/origin/HEAD - origin/master remotes/origin/master git tag # Why don't other branches appear here? # Hm, I'll add --branch master to the command git clone https://github.com/git/git git3 --depth 1 --branch master cd git3 git branch -a * master remotes/origin/HEAD - origin/master remotes/origin/master remotes/origin/next remotes/origin/pu remotes/origin/todo git tag gitgui-0.10.0 gitgui-0.10.1 gitgui-0.10.2 ... # And why DO they appear here? Why do I now get all tags? # Same result for --branch next # okay, let's try adding --single-branch git clone https://github.com/git/git git4 --depth 1 --branch next --single-branch cd git4 git branch -a * next remotes/origin/next remotes/origin/pu remotes/origin/todo # Now I don't get master, but I still get those other branches??? And also tags? Now I am aware that a bug was fixed in git 1.8.0: https://raw.github.com/gitster/git/master/Documentation/RelNotes/1.8.0.txt * A repository created with git clone --single had its fetch refspecs set up just like a clone without --single, leading the subsequent git fetch to slurp all the other branches, defeating the whole point of specifying only this branch. But even considering that bug (and assuming it also affected git clone), the results I get for 1.7.10.4 seem all weird, and not really following the documentation. So I am sorry I cannot phrase this as a single question, as the results are not consistent with each other or the documentation, and those results seem to be related. cheers, Thibault Kruse How to create local repo1: mkdir repo1 cd repo1 git init echo 0 foo.txt git add foo.txt git commit -m 0 git co master -b bar echo 1 bar.txt git add bar.txt git commit -m 1 git co bar -b foo echo 2 foo.txt git add foo.txt git commit -m 2 echo 3 foo.txt git add foo.txt git commit -m 3 echo 4 foo.txt git add foo.txt git commit -m 4 echo 5 foo.txt git add foo.txt git commit -m 5 git co master echo 1 master.txt git add master.txt git commit -m m1 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git clone combined with --depth, --branch and --single-branch
On Sun, Feb 17, 2013 at 7:29 PM, Thibault Kruse tibokr...@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. 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 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git clone combined with --depth, --branch and --single-branch
Hi Duy, On Sun, Feb 17, 2013 at 3:32 PM, Duy Nguyen pclo...@gmail.com wrote: On Sun, Feb 17, 2013 at 7:29 PM, Thibault Kruse tibokr...@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). 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. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Fwd: git clone combined with --depth, --branch and --single-branch
Actually, using git 1.8.3, I get: git clone repo1 repo2 --depth 1 warning: --depth is ignored in local clones; use file:// instead. ... So I guess the warning says it all, it helps to read it. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html