解决Git版本提交出现的几种错误,都是自己已经解决了的

posted @ Sep 15, 2015

2013-09-16

这个主要是总结一下,我在使用Git的时候遇到的一些问题

问题背景

我使用的是window10系统,当然比不上Mac系统,本来window系统反应有点迟钝,再加上我对Git本来也不是很熟悉,在操作过程中就出现了各种问题。就总结几个已经遇到的问题。

一般,可以在Github上使用HTTPS协议push代码(使用的是用户名在Github上的用户名和密码),但通常来说,使用SSH检出和提交代码是更为安全,更适合团队开发。

Github通过将ssh的连接端口指定为https使用的443,使用了另外一个主机名:ssh.github.com来解决这一问题,这样我们可以通过大多数代理服务器允许的443端口,使用SSH访问Github了。

Git push 403错误

这是权限问题,可以修改.git/config文件,可以手动修改

[remote "origin"]
    url = https://LittlewhiteChen/github.com/LittlewhiteChen/LittlewhiteChen.github.io.git
    //其中LittlewhiteChen是我的用户名。试过一次,可以。

也有第二种方法:

[remote "origin"]
    url = ssh://github.com/LittlewhiteChen/LittlewhiteChen.github.io.git
    //将https改成ssh

这是stackoverflow.com上给出的方法:

Alt text

可以参考一下:解决办法

当然也是可以使用命令行修改的

git remote set-url origin https://youruser:password@github.com/user/repo.git

同样给出参考:

Alt text

Git push 443错误

这个问题是由于代理服务器参数出现了问题,有如下的解决办法:

git config --global http.proxy http[s]://userName:password(encoded)@proxyaddress:port

还有一个方法:

If your country block github, e.g. China mainland, then you can build a proxy, e.g. use goagent & gae, then set proxy address for git, e.g.

git config --global http.proxy 127.0.0.1:8087

可以看出还是代理服务器

顺便设置一下这个(如果配置文件里没有的话)

git config --global http.sslverify false