Git连接GitHub

其实这个内容就是git如何添加和使用远程库

参考:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000

(一)使用ssh协议:

(1)首先使用:ssh-keygen -t rsa来产生公钥和私钥,默认目录是~/.ssh

当然,在设置过程中你也可以自己选择存放目录,不过没必要更改。

(2)将生成的id_rsa.pub的内容复制到github网站的,account setting->ssh keys

(二)https协议

上一步有可能会出现:ssh: connect to host github.com port 22: Connection timed out

这时候就采用http协议,但是会很慢很慢。

具体参考:

The reason could be the firewall modification as you are under a network.(In which case they may deliberately block some ports)
To double check if this is the reason ... do

ssh -T git@github.com

this should timeout. If that's the case use http protocol instead of ssh this way
just change your url in the config file to http.
Here is how :-

git config --local -e

change entry of

 url = git@github.com:username/repo.git

to

url = https://github.com/username/repo.git

另外,在github网站上也有介绍。https://help.github.com/articles/set-up-git
原文地址:https://www.cnblogs.com/cane/p/3904442.html