一、遇到的問題
按照github上的說明進行操作
grpc/BUILDING.md at master · grpc/grpc
Unix
$ git clone -b v1.28.0-pre3 https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
克隆最新release版本v1.28.0-pre3,但是克隆速度巨慢。
二、解決辦法
通過碼雲導入github地址之後克隆速度顯著提升。
我已經將https://github.com/grpc/grpc導入我的碼雲倉庫,可以直接克隆。
git clone https://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 = https://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 = https://gitee.com/chenwr2020/protobuf.git
branch = 3.0.x
[submodule "third_party/gflags"]
path = third_party/gflags
url = https://gitee.com/chenwr2020/gflags.git
[submodule "third_party/googletest"]
path = third_party/googletest
url = https://gitee.com/chenwr2020/googletest.git
[submodule "third_party/benchmark"]
path = third_party/benchmark
url = https://gitee.com/chenwr2020/benchmark.git
[submodule "third_party/boringssl-with-bazel"]
path = third_party/boringssl-with-bazel
url = https://gitee.com/chenwr2020/boringssl.git
[submodule "third_party/cares/cares"]
path = third_party/cares/cares
url = https://gitee.com/chenwr2020/c-ares.git
branch = cares-1_12_0
[submodule "third_party/bloaty"]
path = third_party/bloaty
url = https://gitee.com/chenwr2020/bloaty.git
[submodule "third_party/abseil-cpp"]
path = third_party/abseil-cpp
url = https://gitee.com/chenwr2020/abseil-cpp.git
branch = lts_2020_02_25
[submodule "third_party/envoy-api"]
path = third_party/envoy-api
url = https://gitee.com/chenwr2020/data-plane-api.git
[submodule "third_party/googleapis"]
path = third_party/googleapis
url = https://gitee.com/chenwr2020/googleapis.git
[submodule "third_party/protoc-gen-validate"]
path = third_party/protoc-gen-validate
url = https://gitee.com/chenwr2020/protoc-gen-validate.git
[submodule "third_party/udpa"]
path = third_party/udpa
url = https://gitee.com/chenwr2020/udpa.git
[submodule "third_party/libuv"]
path = third_party/libuv
url = https://gitee.com/chenwr2020/libuv.git
git submodule update --init 會克隆一些子模塊倉庫。自動安裝這些第三方模塊倉庫還是很慢,我已經將第三方模塊的倉庫都導入我的碼雲倉庫。
速度提升不止一個檔次。
三、碼雲導入github
登錄碼雲註冊賬號。
導入成功後
之後克隆顯示需要添加公鑰。
在你要添加的機器中獲取自己原先github生成的密鑰。
具體如何生成可以參考博客:
ubuntu14.04 Git Github環境搭建設置_chenwr2018的博客-CSDN博客
將上述文件獲取的內容複製粘貼後生成公鑰。
到此就可以愉快的克隆了。