git clone error: RPC failed; result=22, HTTP code = 502

git克隆的工程太大用https的方式会有如下问题

<pre>
hbl:tmp hubert$ git clone https://your-git-project.git
Cloning into ‘aios-for-robot’…
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
</pre>

解决方法如下

  1. 通过–depth=1参数解决,拉取的只是master分支的shallow,只是最新的commit
    <pre>
    hbl:tmp hubert$ git clone –depth=1 https://your-git-project.git
    Cloning into ‘aios-for-robot’…
    remote: Counting objects: 311, done.
    remote: Compressing objects: 100% (257/257), done.
    remote: Total 311 (delta 49), reused 158 (delta 33)
    Receiving objects: 100% (311/311), 35.17 MiB | 92.00 KiB/s, done.
    Resolving deltas: 100% (49/49), done.
    Checking connectivity… done.
    </pre>

  2. 对于在分支开发的开发者来说,不幸的是–depth=1不会把分支拉下来,于是要如下方式,拉取分支到本地
    <pre>
    hbl:aios-for-robot hubert$ git fetch origin lechange:lechange
    remote: Counting objects: 12, done.
    remote: Compressing objects: 100% (11/11), done.
    remote: Total 12 (delta 3), reused 0 (delta 0)
    Unpacking objects: 100% (12/12), done.
    From https://your-git-project/aios/aios-for-robot

  • [new branch] lechange -> lechange
    </pre>
  1. 拉到本地的分支,并不是远程分支,需要设置upstream提交修改
    <pre>
    hbl:aios-for-robot hubert$ git push
    fatal: The current branch lechange has no upstream branch.
    To push the current branch and set the remote as upstream, use

    git push –set-upstream origin lechange
    </pre>
    <pre>
    hbl:aios-for-robot hubert$ git push –set-upstream origin lechange
    Counting objects: 2, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (2/2), 315 bytes | 0 bytes/s, done.
    Total 2 (delta 0), reused 0 (delta 0)
    To https://your-git-project.git
    02a4c0c..f4f5357 lechange -> lechange
    Branch lechange set up to track remote branch lechange from origin.
    </pre>

    原文作者:刘洪彬
    原文地址: https://www.jianshu.com/p/645d3fe4e028
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞