当项目过大时,git clone时会出现error: RPC failed; HTTP 504 curl 22 The requested URL returned error: 504 Gateway Time-out的问题
但是使用了 --depth=1命令后,只会拉取最近的一次提交,如果需要获取其他分支需要进行进一步的修改:
1.先转换存储库为完整存储库
-
git pull --unshallow
-
#或者
-
git fetch --unshallow
此命令用于将非浅层转换为完整的存储库,消除浅层存储库所施加的所有限制
。
2.修改.git
文件夹内config
文件的[remote "origin"]
节的内容
修改前
-
[remote "origin"]
-
url = https://xxx.com/abc/xxx.git
-
fetch = +refs/heads/master:refs/remotes/origin/master
修改后
-
[remote "origin"]
-
url = https://xxx.com/abc/xxx.git
-
fetch = +refs/heads/*:refs/remotes/origin/*
以上步骤也可用命令代替
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
3.然后执行以下命令获取所有分支
git fetch -pv