Transport Error: Cannot get remote repository refs.https://github.com/xxx/test1.git: cannot open git-upload-pack

问题出现:

  在eclipse中pull项目至github上出现该问题

 

 查看报错日志

org.eclipse.jgit.api.errors.TransportException: https://github.com/muzhiyi1996/test1.git: cannot open git-upload-pack
    at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:222)
    at org.eclipse.jgit.api.LsRemoteCommand.call(LsRemoteCommand.java:161)
    at org.eclipse.egit.core.op.ListRemoteOperation.run(ListRemoteOperation.java:116)
    at org.eclipse.egit.ui.internal.components.RefSpecPage$2.run(RefSpecPage.java:255)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:122)
Caused by: org.eclipse.jgit.errors.TransportException: https://github.com/muzhiyi1996/test1.git: cannot open git-upload-pack
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:624)
    at org.eclipse.jgit.transport.TransportHttp.openFetch(TransportHttp.java:391)
    at org.eclipse.jgit.api.LsRemoteCommand.execute(LsRemoteCommand.java:200)
    ... 4 more
Caused by: java.net.ConnectException: Connection time out: github.com
    at org.eclipse.jgit.util.HttpSupport.response(HttpSupport.java:235)
    at org.eclipse.jgit.transport.TransportHttp.connect(TransportHttp.java:539)
    ... 6 more

 

经过百度后解决方案尝试如下:

1.日志显示连接超时,所以直接更改超时时间

  Preferences-->Team-->Git,修改为300

  该方法尝试无效

  

 2.Preferences-->Team-->Git-->Configuration-->User Settings.然后点Add Entry新建一个键值对,输入http.sslVerify=false

  该方法尝试后无效

 

 

3.修改eclipse.ini文件

  在文件中添加  -Dhttps.protocols=TLSv1,TLSv1.1,TLSv1.2。

  这个问题是说旧版eclipse默认JDK版本是1.7,默认支持TLSv1.1,Git现在不支持该协议。而JDK版本是1.8的话,默认支持TLSv1.2,不会有该问题

  我的JDK版本是1.8,没有该问题,但还是将该方法放在此处,希望对他人有所帮助

4..Preferences-->General-->Network Connection,修改Active Provider为Direct

  该方法尝试后依旧无效

 

5.上述办法都无效后,在百度时突然想起来ping网址,因为我是能登录github.com的,所以一直没想到该问题,之后cmd-->ping github.com

 

 问题原因找到了,解决:

  https://www.ipaddress.com/ip-lookup 在该网址输入github.com,查出一个ip地址,

  打开C:\Windows\System32\drivers\etc\hosts文件,在末尾添加 ip地址+github.com

 

 

 

 再次ping github

 

 问题解决!eclipse问题也解决

posted @ 2020-07-12 21:13  木之一  阅读(1434)  评论(0编辑  收藏  举报