Git 克隆大型仓库失败解决方法

# 问题

克隆一个大型仓库,约 270 M

git clone https://xxxxxx.git,报错:

error: pack-objects died of signal 15, 37.61 MiB | 265.00 KiB/s
remote: aborting due to possible repository corruption on the remote side.
error: git upload-pack: git-pack-objects died with error.
fatal: git upload-pack: aborting due to possible repository corruption on the remote side.
Gitea: Internal error
Failed to execute git command: exit status 128
fatal: index-pack failed
1
2
3
4
5
6
7

# 解决方案

# 分步克隆

克隆最新一次 commit

$ git clone https://xxxxxx.git --depth 1
1

然后下载所有历史

$ git fetch --unshallow
1

或者克隆剩余所有

$ git remote set-branches origin '*'
$ git fetch -v
1
2

或者克隆某一分支

$ git remote set-branches origin 'cnguu'
$ git fetch origin cnguu
$ git checkout cnguu
1
2
3