当前位置:   article > 正文

vscode push 到 github 的问题_vscode中推送代码到github失败

vscode中推送代码到github失败

生成ssh

 ssh-keygen -t rsa -b 4096 -C "XXX@XXX.com"
  • 1

查看私钥
cat ~/.ssh/id_rsa.pub
将显示的内容复制到github的ssh中

git remote add origin git@github.com:XXX/XXX.git
  • 1

(如果报错,可以用这一句替换: 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
  • 1

如果还不行,
【方案二】22不行就试试443

ssh -T -p 443 git@ssh.github.com
  • 1
vim ~/.ssh/config
  • 1

给~/.ssh/config文件里添加如下内容:
ssh连接GitHub的时会使用443端口)

Host github.com
    Hostname ssh.github.com
    Port 443
  • 1
  • 2
  • 3

这下就push成功了!

 git push -u origin master
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/589401
推荐阅读
相关标签
  

闽ICP备14008679号