解决gRPC源码克隆速度慢的问题

一、遇到的问题

按照github上的说明进行操作

grpc/BUILDING.md at master · grpc/grpc

image

Unix
 $ git clone -b v1.28.0-pre3 https://github.com/grpc/grpc
 $ cd grpc
 $ git submodule update --init

克隆最新release版本v1.28.0-pre3,但是克隆速度巨慢。


image

二、解决办法

通过码云导入github地址之后克隆速度显著提升。

我已经将https://github.com/grpc/grpc导入我的码云仓库,可以直接克隆。

git clone git@gitee.com:chenwr2020/grpc.git
git checkout -b grpc_v1.28.0-pre3 v1.28.0-pre3

克隆完毕之后再切换release版本tag分支,具体可以根据实际需求来选择分支。

在grpc目录下打开.gitmodules,默认为:

[submodule "third_party/zlib"]
    path = third_party/zlib
    url = https://github.com/madler/zlib
    # When using CMake to build, the zlib submodule ends up with a
    # generated file that makes Git consider the submodule dirty. This
    # state can be ignored for day-to-day development on gRPC.
    ignore = dirty
[submodule "third_party/protobuf"]
    path = third_party/protobuf
    url = https://github.com/google/protobuf.git
    branch = 3.0.x
[submodule "third_party/gflags"]
    path = third_party/gflags
    url = https://github.com/gflags/gflags.git
[submodule "third_party/googletest"]
    path = third_party/googletest
    url = https://github.com/google/googletest.git
[submodule "third_party/benchmark"]
    path = third_party/benchmark
    url = https://github.com/google/benchmark
[submodule "third_party/boringssl-with-bazel"]
    path = third_party/boringssl-with-bazel
    url = https://github.com/google/boringssl.git
[submodule "third_party/cares/cares"]
    path = third_party/cares/cares
    url = https://github.com/c-ares/c-ares.git
    branch = cares-1_12_0
[submodule "third_party/bloaty"]
    path = third_party/bloaty
    url = https://github.com/google/bloaty.git
[submodule "third_party/abseil-cpp"]
    path = third_party/abseil-cpp
    url = https://github.com/abseil/abseil-cpp.git
    branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
    path = third_party/envoy-api
    url = https://github.com/envoyproxy/data-plane-api.git
[submodule "third_party/googleapis"]
    path = third_party/googleapis
    url = https://github.com/googleapis/googleapis.git
[submodule "third_party/protoc-gen-validate"]
    path = third_party/protoc-gen-validate
    url = https://github.com/envoyproxy/protoc-gen-validate.git
[submodule "third_party/udpa"]
    path = third_party/udpa
    url = https://github.com/cncf/udpa.git
[submodule "third_party/libuv"]
    path = third_party/libuv
    url = https://github.com/libuv/libuv.git

修改为

[submodule "third_party/zlib"]
    path = third_party/zlib
    url = git@gitee.com:chenwr2020/zlib.git
    # When using CMake to build, the zlib submodule ends up with a
    # generated file that makes Git consider the submodule dirty. This
    # state can be ignored for day-to-day development on gRPC.
    ignore = dirty
[submodule "third_party/protobuf"]
    path = third_party/protobuf
    url = git@gitee.com:chenwr2020/protobuf.git
    branch = 3.0.x
[submodule "third_party/gflags"]
    path = third_party/gflags
    url = git@gitee.com:chenwr2020/gflags.git
[submodule "third_party/googletest"]
    path = third_party/googletest
    url = git@gitee.com:chenwr2020/googletest.git
[submodule "third_party/benchmark"]
    path = third_party/benchmark
    url = git@gitee.com:chenwr2020/benchmark.git
[submodule "third_party/boringssl-with-bazel"]
    path = third_party/boringssl-with-bazel
    url = git@gitee.com:chenwr2020/boringssl.git
[submodule "third_party/cares/cares"]
    path = third_party/cares/cares
    url = git@gitee.com:chenwr2020/c-ares.git
    branch = cares-1_12_0
[submodule "third_party/bloaty"]
    path = third_party/bloaty
    url = git@gitee.com:chenwr2020/bloaty.git
[submodule "third_party/abseil-cpp"]
    path = third_party/abseil-cpp
    url = git@gitee.com:chenwr2020/abseil-cpp.git
    branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
    path = third_party/envoy-api
    url = git@gitee.com:chenwr2020/data-plane-api.git
[submodule "third_party/googleapis"]
    path = third_party/googleapis
    url = git@gitee.com:chenwr2020/googleapis.git
[submodule "third_party/protoc-gen-validate"]
    path = third_party/protoc-gen-validate
    url = git@gitee.com:chenwr2020/protoc-gen-validate.git
[submodule "third_party/udpa"]
    path = third_party/udpa
    url = git@gitee.com:chenwr2020/udpa.git
[submodule "third_party/libuv"]
    path = third_party/libuv
    url = git@gitee.com:chenwr2020/libuv.git

git submodule update --init 会克隆一些子模块仓库。自动安装这些第三方模块仓库还是很慢,我已经将第三方模块的仓库都导入我的码云仓库。


image

image

速度提升不止一个档次。

三、码云导入github

登录码云注册账号。

image
image

导入成功后


image
image

之后克隆显示需要添加公钥。

image

在你要添加的机器中获取自己原先github生成的密钥。
具体如何生成可以参考博客:
ubuntu14.04 Git Github环境搭建设置_chenwr2018的博客-CSDN博客

image

将上述文件获取的内容复制粘贴后生成公钥。


image

image

到此就可以愉快的克隆了。


image
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 这篇博文是自己在学习git过程中的思考总结。本文仅仅代表个人的看法,如有不妥地方还请本文文末留言。 😊 原文链接g...
    Ming_Hu阅读 1,130评论 4 18
  • 一、常用终端指令 $ pwd用于查看当前目录 $ mkdir learngit 创建一个名为learngit的空目...
    天山雪莲_38324阅读 474评论 0 1
  • 多种多样的工作流使得在项目中实施Git时变得难以选择。这份教程提供了一个出发点,调查企业团队最常见的Git工作流。...
    JSErik阅读 4,483评论 2 8
  • 等着这儿到了临近路灯熄灭的时间,家家户户基本都已熄灯睡下后。我便和小伙伴提前穿着拖鞋,一人扛着相机、三脚架...
    鱼魂酿酒阅读 282评论 1 6
  • 主题:好玩的小姐姐 今天认识了一位青岛的弹阮的小姐姐,妈呀,一聊聊了3小时……那就讲讲这位小姐姐的好玩呀 1.去苏...
    海珍_你好呀阅读 650评论 0 0