git clone 太慢怎么办
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git clone 太慢怎么办相关的知识,希望对你有一定的参考价值。
参考技术A 步骤如下:1. clone最新一个提交
```
$ git clone --depth=1 git@github.com:atom/atom.git
Cloning into 'atom'...
remote: Counting objects: 444, done.
remote: Compressing objects: 100% (359/359), done.
remote: Total 444 (delta 20), reused 264 (delta 8)
Receiving objects: 100% (444/444), 2.25 MiB | 7.00 KiB/s, done.
Resolving deltas: 100% (20/20), done.
Checking connectivity... done.
```
2. 更新获取完整历史版本
```
$ git fetch --unshallow
remote: Counting objects: 98400, done.
remote: Compressing objects: 100% (27919/27919), done.
remote: Total 98159 (delta 68929), reused 97823 (delta 68611)
Receiving objects: 100% (98159/98159), 236.07 MiB | 18.00 KiB/s, done.
Resolving deltas: 100% (68929/68929), completed with 175 local objects.
From github.com:atom/atom
dbe15f7..7cdaaf2 master -> origin/master
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 7 (delta 0), reused 7 (delta 0)
Unpacking objects: 100% (7/7), done.
* [new tag] v0.0.1 -> v0.0.1
* [new tag] v0.0.2 -> v0.0.2
...此处省略91行
* [new tag] v0.92.0 -> v0.92.0
* [new tag] v0.93.0 -> v0.93.0
* [new tag] v0.94.0 -> v0.94.0
```
期间也中断过,和直接clone一样,都不支持续传。
下面的事实可以说明我这里速度有多慢:
unshallow后git status一看:
```
$ git st
On branch master
Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
nothing to commit, working directory clean
```
centos服务器上git clone下载加速
最近在服务器上直接git clone github上的仓库,下载速度只有十几KB,简直不要太慢!
网上搜了一些加速的,自己于是写了下面的总结。
1. nslookup命令
如果执行这个命令找不到,请先执行:
yum -y install bind-utils
然后执行下面两条命令
nslookup github.global.ssl.fastly.Net
nslookup github.com
如图:
2. 修改hosts文件
写上对应的IP
X.X.X.X http://global-ssl.fastly.net
X.X.X.X http://github.com
3. 刷新缓存
yum install -y nscd
service nscd restart
再执行git clone下载速度应该就比较快了!
以上是关于git clone 太慢怎么办的主要内容,如果未能解决你的问题,请参考以下文章