getting-started-with-javascript icon indicating copy to clipboard operation
getting-started-with-javascript copied to clipboard

在同步仓库git fetch upstream master时出现错误提示Operation timed out及解决方法

Open antarts opened this issue 8 years ago • 5 comments

碰到一个问题

仓库同步时出错

按照 @Dream4ever 同学的《Git常用操作笔记》文档里面的提示操作,将自己的仓库和老师的仓库同步。在执行:

git fetch upstream master

出现以下错误提示:

git fetch upstream master
fatal: unable to access 'https://github.com/xugy0926/getting-started-with-javascript.git/': Failed to connect to github.com port 1080: Operation timed out
 ✘ antarts@wukuipindeMacBook-Pro ⮀ ~/javascriptbridge/getting-started-with-javascript ⮀ ⭠ lesson3_homework_wukuipin ⮀ git remote -v
origin	[email protected]:antarts/getting-started-with-javascript.git (fetch)
origin	[email protected]:antarts/getting-started-with-javascript.git (push)
upstream	https://github.com/xugy0926/getting-started-with-javascript.git (fetch)
upstream	https://github.com/xugy0926/getting-started-with-javascript.git (push)

解决办法

  1. 在终端执行:
git remote rm upstream
  1. 将 https:// 更换为 git@ ,同样终端执行:
it remote add upstream [email protected]:xugy0926/getting-started-with-javascript.git
  1. 然后再按照《Git常用操作笔记》往下操作即可。

这是我更换后,成功同步的画面:

总结

对于出现这个问题的原因不是很了解,似乎是代理的问题。希望这能帮助到遇到同样问题的同学!

antarts avatar Aug 18 '17 08:08 antarts

有时候网络不好,就会这样,可以先去忙别的事情,过一会儿再试试。

Dream4ever avatar Aug 18 '17 09:08 Dream4ever

@Dream4ever 我是把仓库地址上的 https:// 换成 git@ 才成功,也不知道为什么😂

antarts avatar Aug 18 '17 12:08 antarts

@antarts 能从不同的角度去尝试,很好的思维方式啊,加油~~~

Dream4ever avatar Aug 18 '17 15:08 Dream4ever

一般都是网络问题。此时,你可以用ping指令来测试一下目标url

xugy0926 avatar Aug 18 '17 16:08 xugy0926

原来是我的git代理出了问题,取消代理就可以了。 git config --global --unset https.proxy

这里是方法出处

antarts avatar Sep 22 '17 08:09 antarts