問題出現:
在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問題也解決