当尝试配置GIT时,Eclipse没有响应

9

Windows 10专业版 64位
固态硬盘 Kingston
i5-4690处理器
Eclipse版本:全部
工作区:空的
问题:每次我尝试配置TEAM > GIT > 配置或者导入/创建本地/远程GIT时,Eclipse都会冻结直到我被迫使用任务管理器强制关闭它。
我已经尝试过新安装(juno/mars/neon/oxygen)32/64位版本,有安装程序和无安装程序版本,但没有好的结果。

!SESSION 2017-06-27 00:39:29.113 -----------------------------------------------
eclipse.buildId=4.7.0.I20170531-2000
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.egit.ui 2 0 2017-06-27 00:39:50.111
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Enrico'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2017-06-27 00:41:04.510 -----------------------------------------------
eclipse.buildId=4.7.0.I20170531-2000
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product -data file:/C:/Users/Enrico/workspace/ -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.egit.ui 2 0 2017-06-27 00:41:13.439
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Enrico'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2017-06-27 00:42:32.097 -----------------------------------------------
eclipse.buildId=4.7.0.I20170531-2000
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.egit.ui 2 0 2017-06-27 00:42:42.119
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Enrico'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2017-06-27 00:45:05.785 -----------------------------------------------
eclipse.buildId=4.7.0.I20170531-2000
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.java.product -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product -data file:/C:/Users/Enrico/workspace/ -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.egit.ui 2 0 2017-06-27 00:45:13.542
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Enrico'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2017-06-27 00:47:39.707 -----------------------------------------------
eclipse.buildId=4.7.0.I20170531-2000
java.version=1.8.0_91
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=it_IT
Framework arguments:  -product org.eclipse.epp.package.java.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.java.product

!ENTRY org.eclipse.egit.ui 2 0 2017-06-27 00:47:49.374
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'C:\Users\Enrico'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

我的解决方案: "删除用户文件夹(.p2 .eclipse)和PROGRAMFILES中的所有文件夹。记得重新启动电脑!!!现在使用Eclipse Oxygen和Git项目一切正常"


你好。你成功让它工作了吗?我在升级到Win Pro 64位的Windows Creators Update后遇到了完全相同的问题。 - Stefaan Neyts
删除 USER_FOLDER(.p2 .eclipse)和 PROGRAMFILES 中的所有文件夹。记得重新启动电脑!!!现在 Eclipse Oxygen 和 Git 项目都可以正常工作了。 - enrico-dev
5个回答

22

Eclipse 的 GIT 插件会尝试检测操作系统的 GIT 可执行文件或内置的 GIT,并使用 bash 命令进行判断。

在 Windows 创意者更新之前,bash 命令不存在(除非您安装了 CygWin 或类似的程序)。随着 Windows 创意者更新,添加了一个新功能 Windows Subsystem for Linux。当首次调用 bash 命令时,会询问是否安装此功能。

因此,为了修复 Eclipse 中的 GIT,您只需手动运行一次 bash 并安装它即可。您可能需要在 Windows 中激活开发人员模式。


你的解决方案对我很有帮助。我已经为此苦苦挣扎了好几天。只是出于好奇,你是如何得出这个解决方案的? - Kush
好久不见了,但如果我没记错的话,我是通过查看Eclipse Git插件eGit的源代码找到了答案。 - Stefaan Neyts
非常感谢。我绝望地寻找解决方案。 - seekme_94
这是糟糕的设计。Windows版本至少应该使用批处理命令。知道可以在哪里报告吗? - gagarwa

4
我曾经遇到过同样的问题:当我尝试配置git时,Eclipse无法响应。
我使用了Java VisualVM并发现Eclipse没有响应是因为它在搜索git时卡住了。
 at java.io.FileInputStream.readBytes(Native Method)
    at java.io.FileInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    - locked <0x00000000cf57bf60> (a java.io.BufferedInputStream)
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    - locked <0x00000000cf382838> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(Unknown Source)
    at java.io.BufferedReader.fill(Unknown Source)
    at java.io.BufferedReader.readLine(Unknown Source)
    - locked <0x00000000cf382838> (a java.io.InputStreamReader)
    at java.io.BufferedReader.readLine(Unknown Source)
    at org.eclipse.jgit.util.FS.readPipe(FS.java:528)
    at org.eclipse.jgit.util.FS.readPipe(FS.java:479)
    at org.eclipse.jgit.util.FS_Win32.discoverGitExe(FS_Win32.java:127)
    at org.eclipse.jgit.util.FS.discoverGitSystemConfig(FS.java:647)

我使用的是Windows系统,已经安装了Git for Windows,但由于某种奇怪的原因,指向Git的环境变量没有被定义。

我不得不将git.exe所在的目录 (C:\Program Files\Git\bin) 添加到名为Path的系统变量中。

现在,Eclipse不再冻结。


1
在Windows 10上将git添加到路径变量中,使用Eclipse Oxygen对我有用!谢谢 :D

1
嗨,蒂芙尼,欢迎来到SO。请随意扩展您的答案,说明用户如何通过您建议的方法获得积极的结果,以便您的答案看起来更完整。 - alariva

0
Eclipse 可能正在查找 bash 可执行文件。
如果您已安装 Cygwin,请将 Cygwin bin 目录(例如,C:\ cygwin64 \ bin)添加到您的 Path 环境变量中。然后重新启动 Eclipse。
Cygwin bin 目录包括 bash.exe。

0
检查您是否已经安装了Git。 检查环境中的git变量是否设置正确。 尝试在命令提示符中执行git命令,它应该首先正常工作。 一旦完成上述所有步骤,请尝试以清洁模式重新启动eclipse。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接