Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error: could not delete references" due to non-existent lock file #5378

Open
roelandschoukens opened this issue Jan 22, 2025 · 0 comments
Open

Comments

@roelandschoukens
Copy link

roelandschoukens commented Jan 22, 2025

Git is unable to remove a stale remote reference. (this is a branch that was deleted on the remote GIT repository).

$ git fetch
error: could not delete references: cannot lock ref 'refs/remotes/origin/wip/some/branch': Unable to create 'C:/path/to/clone/.git/refs/remotes/origin/wip/some/branch.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.

(branch name and paths shortened, but the paths involved are well within normal path length limits on Windows)

However this lock file does not exist.

Tracing git.exe in procmon shows that the process is creating the file, then noticing its existence, and then removing the file.

time               | name    | PID   | Operation             | Path                                                           | Result         | Detail
-------------------|---------|-------|-----------------------|----------------------------------------------------------------|----------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
9:43:01.4249506 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Created
9:43:01.4250374 am | git.exe | 23220 | QuerySecurityFile     | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        | Information: 0x20
9:43:01.4251863 am | git.exe | 23220 | CloseFile             | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        |
9:43:01.4256310 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.4676144 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.4832797 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.4983944 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.5296357 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.5601606 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.6066284 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | NAME COLLISION | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0
9:43:01.6067965 am | git.exe | 23220 | CreateFile            | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        | Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
9:43:01.6068177 am | git.exe | 23220 | QuerySecurityFile     | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        | Information: 0x20
9:43:01.6068228 am | git.exe | 23220 | QueryAttributeTagFile | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        | Attributes: A, ReparseTag: 0x0
9:43:01.6068296 am | git.exe | 23220 | <Unknown>             | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        |
9:43:01.6068387 am | git.exe | 23220 | CloseFile             | C:\path\to\clone\.git\refs\remotes\origin\wip\some\branch.lock | SUCCESS        |
9:43:01.8263445 am | git.exe | 44796 | CreateFile            | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        | Desired Access: Generic Read/Write, Disposition: Create, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Created
9:43:01.8264466 am | git.exe | 44796 | QuerySecurityFile     | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        | Information: 0x20
9:43:01.8331550 am | git.exe | 44796 | CloseFile             | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        |
9:43:01.8332106 am | git.exe | 44796 | CreateFile            | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        | Desired Access: Read Attributes, Delete, Disposition: Open, Options: Non-Directory File, Open Reparse Point, Attributes: n/a, ShareMode: Read, Write, Delete, AllocationSize: n/a, OpenResult: Opened
9:43:01.8332251 am | git.exe | 44796 | QuerySecurityFile     | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        | Information: 0x20
9:43:01.8332297 am | git.exe | 44796 | QueryAttributeTagFile | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        | Attributes: A, ReparseTag: 0x0
9:43:01.8332356 am | git.exe | 44796 | <Unknown>             | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        |
9:43:01.8332430 am | git.exe | 44796 | CloseFile             | C:\path\to\clone\.git\objects\maintenance.lock                 | SUCCESS        |

Installation info:

$ cat /etc/install-options.txt
Editor Option: Notepad++
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Rebase
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable FSMonitor: Disabled
$ cat /etc/install-options.txt
Editor Option: Notepad++
Custom Editor Path:
Default Branch Option:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: WinSSL
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Git Pull Behavior Option: Rebase
Use Credential Manager: Enabled
Performance Tweaks FSCache: Enabled
Enable Symlinks: Disabled
Enable FSMonitor: Disable
>ver

Microsoft Windows [Version 10.0.22631.4037]```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant