Git 设置代理 加快clone速度

国内访问Github本身就挺难的,但是加上长城宽带简直男上加男

当然直接修改~/.gitconfig文件也可以当然直接修改~/.gitconfig文件也可以

info:Shell走代理的方法:传送门
注意: 代理地址不要加引号,会导致gclient下载出错
1.https.proxy设置是无用的, 只需要设置http.proxy(带查证)
2.使用socks5h://更好, 查询远端DNS

Git设置代理

#设置http代理
git config --global http.proxy socks5://127.0.0.1:1080
#设置https代理
git config --global https.proxy socks5://127.0.0.1:1080
#关闭ssl验证
git config --global http.sslVerify false
git config --global https.sslVerify false

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

Git 取消代理设置

#取消http代理
git config --global --unset http.proxy
#取消https代理
git config --global --unset https.proxy
#开启ssl验证
git config --global http.sslVerify true
git config --global https.sslVerify true

#取消只对github.com代理
git config --global --unset http.https://github.com.proxy

Git clone 报 fatal: protocol 'https' is not supported 错误

Git clone 报 fatal: protocol 'https' is not supported 错误

Git 错误提示信息Git 错误提示信息

Git 错误提示信息Git 错误提示信息

看到 fatal: repository ' ' does not exist

再联想到ctrl + v时候 bash 不自然的错位,怀疑是不是粘贴进去些奇怪的东西。

在记事本中重新粘贴一下

多了些奇怪的的东西多了些奇怪的的东西

好吧。。。

尝试使用shift + insert重新粘贴一下地址。

OK,一切正常了。

Git正常克隆Git正常克隆

Git报错:Could not read from remote repository.

今天新建一个Git仓,远程提交的时候报 Could not read from remote repository. 错误。

具体报错如下:

$ git push -u origin master
ssh: Could not resolve hostname nas-pc192.168.199.102: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

2020-01-18_183224.png2020-01-18_183224.png


感觉可能是密钥出现问题。毕竟好久没用了。(这是个备份仓)

检查发现没有问题。(另一个项目提交没有问题)

2020-01-18_182636.png2020-01-18_182636.png


尝试添加密钥到这个仓库(仍然报错)

#若执行 ssh-add 报:Could not open a connection to your authentication agent. 错误,则先此命令(见下图)
ssh-agent bash

#添加密钥
ssh-add ~/.ssh/id_rsa

尝试添加密钥后仍报错尝试添加密钥后仍报错


观察发现,远程仓库地址不一致,怀疑问题出在这里。

仓库报错仓库报错

实际仓库地址实际仓库地址


重新添加地址,用单引号包裹,ok问题解决。

2020-01-18_183853.png2020-01-18_183853.png

远程仓库添加成功远程仓库添加成功


info:反思:这次问题可能是,命令行把 NAS-PC$@ 中的 $@ 识别为变量,导致地址错误。下次添加时候要用单引号包裹。

Git基础教程

Git是什么?

gitgit

Git是一个分布式版本控制系统。

版本控制是一种记录一个或若干文件内容变化,以便将来查阅特定版本修订情况的系统。

特点

  • 速度
  • 简单的设计
  • 对非线性开发模式的强力支持(允许成千上万个并行开发的分支)
  • 完全分布式
  • 有能力高效管理类似 Linux 内核一样的超大规模项目(速度和数据量)