如何使用缓慢/不稳定的网络连接克隆大型git存储库?

时间:2019-02-14 09:09:40

标签: git

我在这里看到过类似的问题,但是当您处理缓慢/不稳定的网络连接时,它们并没有真正解释如何克隆大型git存储库。

到目前为止,基本上我所做的是:

$ git clone --depth=1 https://salsa.debian.org/kernel-team/linux.git/
Cloning into 'linux'...
remote: Enumerating objects: 1089, done.
remote: Counting objects: 100% (1089/1089), done.
remote: Compressing objects: 100% (738/738), done.
remote: Total 1089 (delta 48), reused 651 (delta 31)
Receiving objects: 100% (1089/1089), 1.49 MiB | 66.00 KiB/s, done.
Resolving deltas: 100% (48/48), done.

该命令只创建了最后一次提交的shallow本地存储库:

$ git log --all --oneline

7d94791 (grafted, HEAD -> refs/heads/master, refs/remotes/origin/master, refs/remotes/origin/HEAD) Update to 4.20.7

现在我应该使用以下命令之一(或它们的某种组合):

$ git fetch --deepen=100
$ git fetch --depth=100

第一个将获取另外100个提交,因此本地存储库现在将具有101个提交。第二个将获取99个提交,本地存储库将总共有100个提交。

我一直在使用价值观,直到最终得到这个:

$ git fetch --depth=10000
remote: Total 0 (delta 0), reused 0 (delta 0)

$ git fetch --unshallow
fatal: --unshallow on a complete repository does not make sense

它说我有一个完整的存储库,但事实并非如此。阅读git stats(在线),我可以看到它具有 13,746次提交,29个分支,1,418个,标签和 2.2 GB 文件。根据类似问题中的信息,如果这是完整克隆,则应该有--depth=13746,但没有事件有10000

这里的问题出在29 Branches中,而我仅克隆了master

这里的问题实际上是:如何以类似的方式克隆其余分支,以便获得整个存储库?

我注意到在.git/config文件中,我具有以下内容:

[remote "origin"]
    url = https://salsa.debian.org/kernel-team/linux.git/
    fetch = +refs/heads/master:refs/remotes/origin/master

当我将第三行更改为:

    fetch = +refs/heads/*:refs/remotes/origin/*

它将获取其余的分支。

我也尝试使用以下内容:

    fetch = +refs/heads/master:refs/remotes/origin/master
    fetch = +refs/heads/sid:refs/remotes/origin/sid

仅提取了sid分支:

$ git remote update && git status                                                                         
Fetching origin                                                                                                                            
remote: Enumerating objects: 209, done.                                                                                                    
remote: Counting objects: 100% (209/209), done.                                                                                            
remote: Compressing objects: 100% (72/72), done.                                                                                           
remote: Total 209 (delta 92), reused 199 (delta 89)                                                                                        
Receiving objects: 100% (209/209), 260.34 KiB | 136.00 KiB/s, done.                                                                        
Resolving deltas: 100% (92/92), done.                                                                                                      
From https://salsa.debian.org/kernel-team/linux                                                                                            
 * [new branch]          sid        -> origin/sid                                                          
On branch master                                                                                                 
Your branch is up to date with 'origin/master'.                                                                                           

nothing to commit, working tree clean

现在我有

$ git branch -a

* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/sid

我认为这里缺少一些内容,但是我真的不知道该做什么以及是否仅添加另外fetch = +refs...行是正确的方法。

我可以通过以下方式获取分支列表:

$ git ls-remote --heads origin
af210b506d24cf7585629e346c921aed90e07133        refs/heads/carnil/import-4.14.14
a56ffb69de38383f26e77b740b9270ee0faf834c        refs/heads/carnil/jessie-security/CVE-2017-7533
7c1804aa712bae44319bd481523c0500df16733b        refs/heads/carnil/stretch-security/CVE-2017-7533
0205ec9ec76ff2d993241a55628e3bd196ecec44        refs/heads/dgit-master
0839599a02f9cbbcb1933e4a60bcbbcf5bcacc11        refs/heads/etch
46f3979bd0f6a567b563f0c99f95c592067e94bb        refs/heads/etch-security
a0fe8cfa8617c895bf6d42383e1975199f342c5b        refs/heads/etchnhalf
66235807ed13884dc8986d9238f83c54baa26ace        refs/heads/etchnhalf-security
7b995d73957608b43a4b2dfacfa9e17bdc37e711        refs/heads/jessie
1d63dcd6296b9ad495d1a7d70c63fa5db68b77b7        refs/heads/jessie-backports
5009a129295a70d8017974c9821ecdd12d7d9675        refs/heads/jessie-security
c7b190d1b45dd7a7df71eb0651b677754972f7fd        refs/heads/jessie-security-4.9
13bc212fa183d61162a1708df0ee9382c0ac66f0        refs/heads/jessie-updates
cd2e2790cfeebeec461ce28530f23b8bf0e24e7b        refs/heads/lenny
14865a3daf8e808072ebca063297815e0967b129        refs/heads/lenny-security
7d94791b95d147a13f2eae4fa9a5e852c95330c9        refs/heads/master
ce61976b4810abb7e88f0bf08dc8efc7e6a19dc5        refs/heads/rosh/armel_mini
26e9f62e399a67e454ff40deca2eef531c279139        refs/heads/sid
9e549e30eb6e12e97f3ff29497821aa41564ee93        refs/heads/squeeze
f8d465883cbbf23432db1d0139f0b43e570ebc9d        refs/heads/squeeze-backports
03cf6ed02e5128674ac954b345cdea2a3c6b9ddd        refs/heads/squeeze-security
155c325ba50c3cdd60d9fcdfdd961a4a636a6367        refs/heads/stretch
5357a00fc4892878f8e532862540a575df621e2c        refs/heads/stretch-backports
0a50b0efbc995f6c5710f4d52e321ef6102ee298        refs/heads/stretch-security
1d69dac66c315a290fb61c5f400e056e8d01fe50        refs/heads/ukleinek/jessie
beed93421656d6290a4fe3952e6a29696a6cbaf7        refs/heads/waldi/cloud-arm64
15ca73ce51f27d275a1e67e570cfe3a13ade3368        refs/heads/wheezy
b479e71dc9fd2215f08b3ea795e0fe9264cc39c3        refs/heads/wheezy-backports
6a47ea238773fa11bb694bd2a0fedc1549dff118        refs/heads/wheezy-security

如何添加和获取(以某种自动化方式)每个分支?

0 个答案:

没有答案