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

"lock file exists" when fetching in bare clone of repository

From
JDJoe Drew <joe.drew@indexexchange.com>
Date
Aug 20, 2025, 20:54 UTC
Message-ID
<YQXPR01MB3046197EF39296549EE6DD669A33A@YQXPR01MB3046.CANPRD01.PROD.OUTLOOK.COM>
Hi there!
I've got what I think is a bug in recent versions of git, at least as packaged for macOS by homebrew.
I'm cloning a fresh copy of a repository into a bare directory:
        $ mkdir tmp
        $ cd tmp
        $ git init --bare
        $ git remote add origin -- <VALID-URL>.git
        $ git fetch -f origin 'refs/heads/*:refs/heads/*' 'refs/tags/*:refs/tags/*'
I'm doing this in a sort of roundabout way because this is exactly what `go mod download` does.
The fetch fails, returning status 255, with the below error message:
        remote: Enumerating objects: 18733, done.
        remote: Counting objects: 100% (562/562), done.
        remote: Compressing objects: 100% (448/448), done.
        remote: Total 18733 (delta 399), reused 144 (delta 112), pack-reused 18171
        Receiving objects: 100% (18733/18733), 25.32 MiB | 7.93 MiB/s, done.
        Resolving deltas: 100% (14608/14608), done.
        From <VALID-URL>
        [.... quite a number of branches and tags .....]
        error: cannot lock ref 'refs/heads/ptv-2164': Unable to create '/Users/joe.drew/tmp/./refs/heads/ptv-2164.lock': File exists.
        Another git process seems to be running in this repository, e.g.
        an editor opened by 'git commit'. Please make sure all processes
        are terminated then try again. If it still fails, a git process
        may have crashed in this repository earlier:
        remove the file manually to continue.
This file doesn't exist; in fact, no such files exist:
        $ ls refs/heads
        $
However, the branch _does_ exist on the remote.
This error _does not_ happen in the Apple-supplied version of git: `git version 2.39.5 (Apple Git-154)`, but does in 2.51.0, which I installed with homebrew. (If this is a packaging error, I'll happily report to homebrew.)
I'd be more than happy to continue debugging this, though I can't share the repository as it's proprietary. I've also attached the git diagnostics, but they're not particularly helpful, I don't think.
[System Info]
git version:
git version 2.51.0
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
libcurl: 8.7.1
zlib: 1.2.12
SHA-1: SHA1_DC
SHA-256: SHA256_BLK
default-ref-format: files
default-hash: sha1
uname: Darwin 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041 arm64
compiler info: clang: 17.0.0 (clang-1700.0.13.3)
libc info: no libc information available
$SHELL (typically, interactive shell): /opt/homebrew/bin/bash
[Enabled Hooks]
CONFIDENTIALITY NOTICE AND DISCLAIMER : This telecommunication, including any and all attachments, contains confidential information intended only for the person(s) to whom it is addressed. Any dissemination, distribution, copying or disclosure is strictly prohibited and is not a waiver of confidentiality. If you have received this telecommunication in error, please notify the sender immediately by return electronic mail and delete the message from your inbox and deleted items folders. This telecommunication does not constitute an express or implied agreement to conduct transactions by electronic means, nor does it constitute a contract offer, a contract amendment or an acceptance of a contract offer. Contract terms contained in this telecommunication are subject to legal review and the completion of formal documentation and are not binding until same is confirmed in writing and has been signed by an authorized signatory.
Next: Jeff King
Message 1 of 16 in “"lock file exists" when fetching in bare clone of repository”
  1. Joe DrewAug 20, 2025
  2. Jeff KingAug 20, 2025
  3. Patrick SteinhardtAug 21, 2025
  4. Jeff KingAug 21, 2025
  5. Patrick SteinhardtAug 21, 2025
  6. Junio C HamanoAug 21, 2025
  7. Patrick SteinhardtAug 22, 2025
  8. Karthik NayakAug 22, 2025
  9. Junio C HamanoAug 22, 2025
  10. Karthik NayakAug 28, 2025
  11. Junio C HamanoAug 28, 2025
  12. Karthik NayakSep 1, 2025
  13. Junio C HamanoAug 21, 2025
  14. Joe DrewAug 22, 2025
  15. Jeff KingAug 26, 2025
  16. Patrick SteinhardtSep 2, 2025

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.