git 分批后的数据

如果涉及到大文件的 git 传输, 我们可能会收到下面错误:

sourceTree 的错误。

image

 

命令行的错误:

image

 

$ git clone https://********/gopher.git
Cloning into 'gopher'...
remote: Counting objects: 275, done.
remote: Compressing objects: 100% (234/234), done.
fatal: The remote end hung up unexpectedlyB | 87.00 KiB/s    
fatal: early EOF
fatal: index-pack failed

网上提到的解决方案有下面几个:

修改 git 的默认 postBuffer 的大小

如果 是需要 post 的文件比较大, 则可通过修改 git 的默认 postBuffer 的大小

linux

$ git config http.postBuffer 524288000

全局的设置则可以是:

$ git config --global http.postBuffer 524288000

windows:
在 .git/config 文件中加入
[http]
postBuffer = 524288000

http://blog.sina.com.cn/s/blog_71d4414d0100wfwq.html 

 

分步下载

 

First, turn off compression:

$ git config --global core.compression 0
Next, let's do a partial clone to truncate the amount of info coming down:

$ git clone --depth 1 <repo_URI>
When that works, go into the new directory and retrieve the rest of the clone:

$ git fetch --unshallow
or, alternately,

$ git fetch --depth=2147483647
Now, do a regular pull:

$ git pull --all
I think there is a glitch with msysgit in the 1.8.x versions that exacerbates these symptoms, so another option is to try with an earlier version of git (<= 1.8.3, I think).

当然 git clone 可以变成下面几步:

$ git init
Initialized empty Git repository in /Users/ghj1976/Documents/work/wangpos/git/gopher/.git/


$ git remote add origin https://******/gopher.git

$ git pull --depth 1
remote: Counting objects: 141, done.
remote: Compressing objects: 100% (114/114), done.
remote: Total 141 (delta 4), reused 0 (delta 0)
Receiving objects: 100% (141/141), 1.68 MiB | 45.00 KiB/s, done.
Resolving deltas: 100% (4/4), done.
From https://******/gopher
* [new branch]      master     -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

 

这里面的 关键 就是用 –depth 获得最近几次的更新记录。 这个数字可以是任意的int数字。

git clone YOUR_REPO --depth=1
git fetch --depth=10
...
git fetch --depth=100
git fetch --unshallow    //Downloads all history allowing to push from repo

--depth <depth>
Create a shallow clone with a history truncated to the specified number of revisions. A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.

参考资料:

http://stackoverflow.com/questions/21277806/fatal-early-eof-fatal-index-pack-failed

http://stackoverflow.com/questions/4826639/repack-of-git-repository-fails

原文地址:https://www.cnblogs.com/ghj1976/p/5569212.html