如何解决在Eclipse中“添加文件到索引”遇到的问题?

qjp7pelc  于 2023-01-30  发布在  Eclipse
关注(0)|答案(1)|浏览(284)

当我想添加一个项目到index(github)时,我的笔记本电脑上的eclipse出现了问题。无法将资源添加到索引无法将资源添加到索引执行add命令期间捕获到异常
这是我的日志:

!ENTRY org.eclipse.egit.ui 4 0 2023-01-25 20:38:42.622
!MESSAGE Failed to add resource to index
!STACK 1
org.eclipse.core.runtime.CoreException: Failed to add resource to index
    at org.eclipse.egit.core.op.AddToIndexOperation.execute(AddToIndexOperation.java:78)
    at org.eclipse.egit.ui.internal.actions.AddToIndexActionHandler$1.run(AddToIndexActionHandler.java:59)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:225)
    at org.eclipse.egit.core.op.AddToIndexOperation.execute(AddToIndexOperation.java:74)
    ... 2 more
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock C:\Users\motah\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\motah\.git\index.lock, then you may delete the lock file and retry.
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:221)
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:292)
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:258)
    at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1285)
    at org.eclipse.egit.core.RepositoryHandle.lockDirCache(RepositoryHandle.java:319)
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:122)
    ... 3 more
!SUBENTRY 1 org.eclipse.egit.core 4 0 2023-01-25 20:38:42.622
!MESSAGE Failed to add resource to index
!STACK 0
org.eclipse.jgit.api.errors.JGitInternalException: Exception caught during execution of add command
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:225)
    at org.eclipse.egit.core.op.AddToIndexOperation.execute(AddToIndexOperation.java:74)
    at org.eclipse.egit.ui.internal.actions.AddToIndexActionHandler$1.run(AddToIndexActionHandler.java:59)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.jgit.errors.LockFailedException: Cannot lock C:\Users\motah\.git\index. Ensure that no other process has an open file handle on the lock file C:\Users\motah\.git\index.lock, then you may delete the lock file and retry.
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:221)
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:292)
    at org.eclipse.jgit.dircache.DirCache.lock(DirCache.java:258)
    at org.eclipse.jgit.lib.Repository.lockDirCache(Repository.java:1285)
    at org.eclipse.egit.core.RepositoryHandle.lockDirCache(RepositoryHandle.java:319)
    at org.eclipse.jgit.api.AddCommand.call(AddCommand.java:122)
    ... 3 more

有谁能帮我解决这个问题吗?我删除了我的项目,重新做了一个,但是没有成功。我做了其他的项目,也得到了同样的错误。我正在学习如何将eclipse推送到github。我只是在课堂上遇到了这个问题,我们无法解决它。

yquaqz18

yquaqz181#

我刚刚找到了解决方案。我不得不删除。lock文件。现在它工作正常。

相关问题