2012-09-18 155 views
1

我必须处理包含一些二进制文件的git repo。git浅克隆以及分支

我会很感激,如果有人可以解释这对我

>git clone --depth 1 -- ssh://git/foo/bar.git test_d 
Cloning into 'test_d'... 
remote: Counting objects: 289, done. 
remote: Compressing objects: 100% (268/268), done. 
remote: Total 289 (delta 111), reused 120 (delta 19) 
Receiving objects: 100% (289/289), 1.95 MiB | 519 KiB/s, done. 
Resolving deltas: 100% (111/111), done. 

>git clone --depth 1 -b master -- ssh://git/foo/bar.git test_db 
Cloning into 'test_db'... 
remote: Counting objects: 5980, done. 
remote: Compressing objects: 100% (1777/1777), done. 
remote: Total 5980 (delta 3868), reused 5657 (delta 3660) 
Receiving objects: 100% (5980/5980), 36.50 MiB | 1.10 MiB/s, done. 
Resolving deltas: 100% (3868/3868), done. 

>git clone -b master -- ssh://git/foo/bar.git test_b 
Cloning into 'test_b'... 
remote: Counting objects: 6953, done. 
remote: Compressing objects: 100% (1779/1779), done. 
remote: Total 6953 (delta 4419), reused 6946 (delta 4417) 
Receiving objects: 100% (6953/6953), 57.25 MiB | 1.15 MiB/s, done. 
Resolving deltas: 100% (4419/4419), done. 

也就是说,为什么经过-b当它好像它改变--depth行为?

+0

这是一个很好的git列表问题。 – Christopher

回答

0

嗯,我想我找到了解决方案,在相关的问题:Partial clone with Git and Mercurial

> md test_foo 
> cd test_foo 
> git init 
> git remote add origin ssh://git/foo/bar.git 
> git config --local remote.origin.fetch +refs/heads/master:refs/remotes/origin/master 
> git pull --depth 1 
remote: Counting objects: 289, done. 
remote: Compressing objects: 100% (268/268), done. 
remote: Total 289 (delta 111), reused 120 (delta 19) 
Receiving objects: 100% (289/289), 1.95 MiB | 496 KiB/s, done. 
Resolving deltas: 100% (111/111), done. 
From ssh://git/foo/bar.git 
* [new branch]  master  -> origin/master 

,但似乎并不像一个解决方案;/

0

而不是仅仅git clone <url>

使用git clone -b <branch> <url> --depth=1

请看这里:quickly-clone-a-large-git-repo这是我的ference。

+0

你还没有读过这个问题,或者没有看过一个例子。 问题是,当组合-depth和-b时,git下载(几乎)整个存储库因此--depth变得完全无用。 – GiM