git笔记1

今天根据廖雪峰老师的git简单教程学习上传代码的时候遇到了一点小问题,记录一下。

根据教程中的指令,先在命令行执行:

git remote add origin git@github.com:username/learngit.git

然后执行:

git push -u origin master

按下回车,过了一会后返回错误:

ssh: connect to host github.com port 22:Connection timed out

fatal: Could not read from remote respository.

搜了一下,在这里找到了答案:

看字面的意思就是连接超时了,什么原因造成的呢,这个估计是公司网络禁用了SSH的22端口导致的。所幸git提供了https、git、ssh三种协议来读写。

运行git config --local -e打开配置信息。
修改其中的

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

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

这样就改为使用https协议了。提交什么的就OK了。

改的时候注意username前面的":"也要换成"/"。

(url中的repo.git用你自己的repository名字,username用自己的账户名,别照搬)

随手记录一下,备忘。



你可能感兴趣的:(#,git)