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

Re: User-initiated recovery for stale index.lock

From
TJTanga Joris <tangajoris@gmail.com>
Date
Nov 25, 2026, 02:04 UTC
Message-ID
<CAKrRMNpHHHHw3goFMwLKF2GRzQefcXJaXZcjY6yz_7QdbgJ_cA@mail.gmail.com>
In-Reply-To
<CAAQS9U+Ht3x=V3e1XJT9V120Tj5jCuCMTrxTnZyzTpsg-G9uBQ@mail.gmail.com>
Hi Steve,
On Tue, 17 Nov 2026 at 20:51, Steve <steves.sk@gmail.com> wrote:
> Could Git add a user-invoked command to recover from a stale
> `index.lock` when no Git process runs anymore? It could wait briefly,
> then remove the lock and continue, but only if no other Git operation
> contests it.

Git already has part of this. Since Git 2.54 there is core.lockfilePid. With it set, Git writes the PID of the lock holder next to the lock (index~pid.lock), and if it can't take the lock, it tells you whether that process is still running:

  Lock was held by process 99999, which is no longer running; the lock
  file appears to be stale
You still remove index.lock yourself, though.

Jun Wu also has a series in 'seen' that adds core.indexLockTimeout, so that commands wait a little for the index lock before failing [1]. That covers your "wait briefly" suggestion.

Removing the lock automatically is tricky. A PID can be reused by an unrelated process, and it says nothing when the repository is also used from another machine, for example over NFS. When the PID file was discussed, Junio was wary even of telling users to remove the lock [2].

[1] https://lore.kernel.org/git/20261017073231.3357477-1-quark.zju@gmail.com/ [2] https://lore.kernel.org/git/xmqqbjj4hnkr.fsf@gitster.g/

Thanks, Tanga

Previous: SteveNext: Steve
Message 2 of 5 in “User-initiated recovery for stale index.lock”
  1. SteveNov 17, 2026
  2. Tanga JorisNov 25, 2026
  3. SteveNov 25, 2026
  4. Tanga JorisDec 2, 2026
  5. Tanga JorisDec 3, 2026

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.