Question

Sometimes I try to read and write to a Git repository at the same time. But afterwards i get the following error message when i try to commit files:

An error was raised by libgit2. Category = Index (LockedFile). The index is locked. This might be due to a concurrrent or crashed process.

The commit is done as expected, why do i get this error message? How do i get rid of it?

(If a LibGit2Sharp developer sees this: There is a spelling misstake in the error message: concuRRRent.) :D

Was it helpful?

Solution 2

The index is a gateway channel between the git object database and the working directory. It's used when crafting a commit (ie. staging, unstaging, ..) or when checking out files. Thus performing those operations concurrently may raise such kind of errors as both operations will race to gain access to the index.

Some work in being done at the libgit2 level to make usage of the index a better experience for threaded read operations (See libgit2/libgit2#2108 for instance).

However, depending on the kind of read/write operations that you perform, you may not need to go through the index:

  • For instance, navigating a Commit, a Tree or retrieving the content of a Blob won't leverage the index.
  • You may also create Blobs, Trees and Commits without going through the index, by directly inserting objects in the object databases (See this StackOverflow answer for a quick start).

If a LibGit2Sharp developer sees this: There is a Spelling mistake in the error message: concuRRRent.

Good catch! Would you feel like opening a Pull request to help us fix this? ;-)

OTHER TIPS

Dropbox can interfere with git operations too. I pause dropbox syncing before any git sync.

I got the same error once and I removed the index.lock file in .git folder where my repository is created and then the issue got resolved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top