简体   繁体   中英

how to solve 'Adding file to index' has encountered a problem in Eclipse?

I am having problem with eclipse on my laptop while I want to add a project to index(for github). I get this error: Failed to add resource to index Failed to add resource to index Exception caught during execution of add command

this is my log:

!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

Can anyone help me here how I can solve it? I have deleted my project and made another one and it did not work. I did with other projects that I have and I get the same error. I am learning how to push in eclipse to github. I only had this problem at class and we could not solve it.

I just found the solution. I had to delete.lock file. Now it works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM