0
点赞
收藏
分享

微信扫一扫

git push报错:fatal: unable to access ‘https://XXX.git/‘: Failed toconnect to github.com port 443

绣文字 2022-03-30 阅读 125
githubgit

新建远程仓库后,在本地使用ng new 创建了一个angular项目,然后分别用使用一下命令推送到远程新建的仓库:
git init
git add .
git commit -m "init project"
git remote add origin "远程仓库http url"
git push origin master

时报错:fatal: unable to access 'https://github.com/SifiaZiwan/ng-myWYY.git/': Failed to connect to github.com port 443 after 21106 ms: Timed out

网上找了取消代理设置的方法:

git config --global http.proxy
git config --global https.proxy

没有解决问题。
后来找到解决办法:https://blog.csdn.net/weixin_45698935/article/details/106599630
 

我的解决过程:

1.  在C:\Windows\System32\drivers\etc 中使用记事本打开hosts文件
注释了 github 的IP地址和域名的映射,
# Github Start
#192.30.253.118    gist.github.com
#192.30.255.112    github.com
#192.30.255.110    www.github.com
# Github End

2. 输入一下git命令, 问题完美解决!

XXXXX MINGW64 /c/XXX/ng-myWYY (main)
$ git checkout -b dev
Switched to a new branch 'dev'

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git push origin dev
fatal: unable to access 'https://github.com/SifiaZiwan/ng-myWYY.git/': Failed to 
connect to github.com port 443 after 21106 ms: Timed out

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git branch -a
* dev
  main
  master
  remotes/origin/main
  remotes/origin/master

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git push origin dev
fatal: unable to access 'https://github.com/XXX/ng-myWYY.git/': OpenSSL SSL_read: Connection was reset, errno 10054

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git config --global http.proxy

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git config --global --unset http.proxy

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git config --global --unset https.proxy

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git push origin dev
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 379 bytes | 379.00 KiB/s, done.
Total 4 (delta 3), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (3/3), completed with 3 local objects.
remote: 
remote: Create a pull request for 'dev' on GitHub by visiting:
remote:      https://github.com/XXX/ng-myWYY/pull/new/dev
remote:
To https://github.com/XXX/ng-myWYY.git
 * [new branch]      dev -> dev

XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git branch -a
* dev
  main
  master
  remotes/origin/dev
  remotes/origin/main
  remotes/origin/master


XXXXX MINGW64 /c/XXX/ng-myWYY (dev)
$ git checkout main
Switched to branch 'main'
Your branch and 'origin/main' have diverged,
and have 2 and 3 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

XXXXX MINGW64 /c/XXX/ng-myWYY (main)
$ git push origin main
To https://github.com/XXX/ng-myWYY.git
 ! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/XXX/ng-myWYY.git'  
hint: Updates were rejected because the tip of your current branch is behind     
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.       

举报

相关推荐

0 条评论