随笔 - 277  文章 - 35  评论 - 868 

http://www.jianshu.com/p/645d3fe4e028

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

hbl:tmp hubert$ git clone https://gitlab.spetechcular.com/aios/aios-for-robot.git
Cloning into 'aios-for-robot'...
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly

解决方法如下

  1. 通过--depth=1参数解决,拉取的只是master分支的shallow,只是最新的commit

    hbl:tmp hubert$ git clone --depth=1 https://gitlab.spetechcular.com/aios/aios-for-robot.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.
  2. 对于在分支开发的开发者来说,不幸的是--depth=1不会把分支拉下来,于是要如下方式,拉取分支到本地

    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://gitlab.spetechcular.com/aios/aios-for-robot
    * [new branch] lechange -> lechange
  3. 拉到本地的分支,并不是远程分支,需要设置upstream提交修改

    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

    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://gitlab.spetechcular.com/aios/aios-for-robot.git
    02a4c0c..f4f5357 lechange -> lechange
    Branch lechange set up to track remote branch lechange from origin.



文/刘洪彬(简书作者)
原文链接:http://www.jianshu.com/p/645d3fe4e028
著作权归作者所有,转载请联系作者获得授权,并标注“简书作者”。
posted on 2016-12-13 11:59 WNFK 阅读(...) 评论(...) 编辑 收藏