git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: 'Failed to create .git/index.lock'

From
Andreas Krey <a.krey@gmx.de>
Date
Feb 15, 2016, 21:34 UTC
Message-ID
<20160215213436.GB16220@inner.h.apk.li>
In-Reply-To
<5B9871D2-395D-4F0C-94FB-278832FCFD76@gmail.com>
On Mon, 15 Feb 2016 18:06:33 +0000, Lars Schneider wrote:
> Hi Andreas,
> 
> I am looking into a similar issue with SourceTree on Windows right now. However, in my case it only happens when I switch branches.

Semi-bingo. That is actually a difference between the workspace this happens in and the others. This one works on many branches; the others clone anew for each new branch.

I investigated the Git commands that SourceTree triggers and it looks like it is doing something like this:
Show 7 quoted lines
> (1) Run checkout command
> git.exe --no-pager -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false checkout MY-BRANCH
> 
> (2) Run rev-parse command 
> git.exe --no-pager -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false rev-parse HEAD^1
> 
> My assumption is that SourceTree triggers these two commands in parallel and sometimes (2) locks the repo first which makes (1) fail.
That would be partly a bug in SourceTree to do so.
> Does your Git process run on Windows, too?
No. RHEL7 Linux.
> Is there a possibility that you issue Git commands in parallel?

I don't think so, except for background GC (which isn't quite background - one phase seems to still run foregrounded).

> I also have read that certain anti virus software can trigger these errors on Windows.
That is an ugly problem indeed.
> I looked through the Git code found that increasing "core.packedrefstimeout" [1] might help in some cases that trigger this error [2] but not in others [3]. In my case this seems to help. Maybe it's worth a try for you, too?

I may need to look into that. Because sometimes the lock causes my automatic process to fail but the lock file isn't there anymore when I get to cleanup. But sometimes it keeps existing.

Andreas
-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800
Previous: Lars Schneider
Message 3 of 3 in “'Failed to create .git/index.lock'”
  1. Andreas KreyFeb 9, 2016
  2. Lars SchneiderFeb 15, 2016
  3. Andreas KreyFeb 15, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.