小记:git拉取大项目

因为项目太大,然后直接git clone拉不下来代码
会报error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out或者类似的错误

然后就加参数用git clone --depth=10 https://xxx.xxx/xxx.git拉下来了

depth用于指定克隆深度,为10即表示只克隆最近十次commit.

执行完后,项目是拉下来了,但是使用git branch -a查看分支的时候看不到其他远程分支

解决办法:

git remote set-branches --add origin [分支名称]
git fetch origin  [分支名称]
git checkout [分支名称]

然后再用git branch -a查看就能看到相应远程分支了

参考资料:https://stackoverflow.com/questions/23708231/git-shallow-clone-clone-depth-misses-remote-branches

后续补充:

可修改.git/config文件
remote块下面的fetch = +refs/heads/master:refs/remotes/origin/master或者类似配置修改为fetch = +refs/heads/*:refs/remotes/origin/*
有多条fetch配置时删除其他配置
然后执行git fetch -v即可获取到完整分支信息
参考资料2:https://segmentfault.com/q/1010000000409170

更新远程分支信息到本地

git fetch origin --prune
# 二选一即可
git remote prune origin

Git下拉和提交等遇到:fatal: early EOF fatal: index-pack failed

方法一:

找到.gitconfig,添加如下配置。(或者用git config --global命令)

[core]
packedGitLimit = 512m
packedGitWindowSize = 512m
[pack]
deltaCacheSize = 2047m
packSizeLimit = 2047m
windowMemory = 2047m
方法二:

网上看到最多的,

git config --global core.compression 0
方法三:(stackoverflow上面看到的高分解答)

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
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拉取大项目)