From: Steve Date: Wed, 25 Nov 2026 13:06:51 GMT Subject: Re: User-initiated recovery for stale index.lock Message-ID: In-Reply-To: Hi Tanga, Thanks for the links. Since core.lockfilePid already tracks the PID, why couldn't a manual recovery command perform that check itself and remove the lock when explicitly invoked by the user, along with ensuring that we wait for some reasonable time? Removing the file by hand doesn't allow users to apply any safety checks. Thanks, Steve st 25. 11. 2026 o 3:05 Tanga Joris napĂ­sal(a): > > Hi Steve, > > On Tue, 17 Nov 2026 at 20:51, Steve 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