赞
踩
生成ssh
ssh-keygen -t rsa -b 4096 -C "XXX@XXX.com"
查看私钥
cat ~/.ssh/id_rsa.pub
将显示的内容复制到github的ssh中
git remote add origin git@github.com:XXX/XXX.git
(如果报错,可以用这一句替换: git remote set-url origin https://github.com/XXX/XXX.git
)
git push -u origin master
然后就报错:
ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
测试一下是否能连接上
ssh -T -p 443 git@ssh.github.com
下图表示可以连接上:
如果不行,
【方案一】
git config --local -e
修改内容为1或者2(试试哪个能行)
1、url = git@github.com:username/repo.git
2、url = https://github.com/username/repo.git
再试一次
git push -u origin master
如果还不行,
【方案二】22不行就试试443
ssh -T -p 443 git@ssh.github.com
vim ~/.ssh/config
给~/.ssh/config文件里添加如下内容:
(ssh连接GitHub的时会使用443端口)
Host github.com
Hostname ssh.github.com
Port 443
这下就push成功了!
git push -u origin master
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。