Skip to content

Unable to create HEAD.lock when cloning inside directory with permissions in directory without any permissions #2531

Closed
@danthe1st

Description

@danthe1st
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options

git version 2.25.1.windows.1
cpu: x86_64
built from commit: cceb69da75b4906bb04cfb3a2f7f37b12b985ec3
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.19013.1122]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
> type "C:\PRGM\Git\etc\install-options.txt"

Editor Option: Notepad++
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
Tortoise Option: false
CURL Option: OpenSSL
CRLF Option: LFOnly
Bash Terminal Option: ConHost
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

I am working on a german system.

I have installed git in the directory C:\PRGM\Git.

I think I am using a windows insider build.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

cmd

At first, I created a directory parent with a subdirectory child inside C:.

Then, I restricted accessing this directory to administrators.

parent directory

After that, I gave the main user full control over the child subdirectory.

child directory

Then, I tried to clone a repository in the child directory as the main user:

C:\>cd parent
Zugriff verweigert

C:\>cd parent\child

C:\parent\child>git clone https://github.com/octocat/Hello-World.git
Cloning into 'Hello-World'...
remote: Enumerating objects: 13, done.
remote: Total 13 (delta 0), reused 0 (delta 0), pack-reused 13
Unpacking objects: 100% (13/13), 1.53 KiB | 8.00 KiB/s, done.
error: Unable to create 'C:/parent/child/Hello-World/.git/refs/remotes/origin/HEAD.lock': No such file or directory
fatal: unable to update refs/remotes/origin/HEAD

  • What did you expect to occur after running these commands?

I expected that a new directory Hello-World would be created containing a hidden .git directory and a file README.md would be created inside the child directory.

  • What actually happened instead?

The cloning of the repository with the message error: Unable to create 'C:/parent/child/Hello-World/.git/refs/remotes/origin/HEAD.lock': No such file or directory (as seen in the commands section below).

The directory Hello-World was not created.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

I tested it with the repository https://github.com/octocat/Hello-World but it seems to be the same with other repositories.

Notes

Zugriff verweigert means Access denied (when I try to access C:\parent (which is correct)) and Vollzugriff means Full-control

It works if I use the standard/linux version of git in WSL(in the same directory):

C:\parent\child>wsl -- bash --norc
bash-5.0$ ls -la
ls: ..: Permission denied
total 0
drwxrwxrwx 1 dan dan 4096 Mar  1 13:45 .
d--x--x--x 1 dan dan 4096 Mar  1 13:19 ..
bash-5.0$ git clone https://github.com/octocat/Hello-World
Cloning into 'Hello-World'...
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3
Unpacking objects: 100% (3/3), done.
bash-5.0$ ls -la
ls: ..: Permission denied
total 0
drwxrwxrwx 1 dan dan 4096 Mar  1 13:56 .
d--x--x--x 1 dan dan 4096 Mar  1 13:19 ..
drwxrwxrwx 1 dan dan 4096 Mar  1 13:56 Hello-World
bash-5.0$ pwd
/mnt/c/parent/child
bash-5.0$pwd
/mnt/c/parent/child
bash-5.0$ ls -la Hello-World/
total 0
drwxrwxrwx 1 dan dan 4096 Mar  1 13:56 .
drwxrwxrwx 1 dan dan 4096 Mar  1 13:56 ..
drwxrwxrwx 1 dan dan 4096 Mar  1 13:56 .git
-rwxrwxrwx 1 dan dan   56 Mar  1 13:56 README.md
bash-5.0$

The same error occurs if I do it with git bash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions