# windows: error cannot lock ref ... unable to create lock

6 messages from 2019-06-18 to 2019-06-24. Participants: Anthony Sottile, Eric Sunshine, Philip Oakley, Johannes Schindelin.
Thread: https://gitlist.dev/t/51333

## Anthony Sottile, 2019-06-18 16:38

Subject: windows: error cannot lock ref ... unable to create lock
Message-ID: <CA+dzEB=iOsfuZQ5Z8uXO+k6E3WczkLX64yWUpTm1NZBjdd47kg@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEB%3DiOsfuZQ5Z8uXO%2Bk6E3WczkLX64yWUpTm1NZBjdd47kg%40mail.gmail.com

```
I've set up a demo problematic repository on github:
https://github.com/asottile-archive/git-windows-branch-test

The minimal reproduction is:

rm -rf x
git init x
cd x
git remote add origin https://github.com/asottile-archive/git-windows-branch-te>
git fetch origin --tags

Here's the output:

+ git init x
Initialized empty Git repository in C:/Users/IEUser/x/x/.git/
+ cd x
+ git remote add origin
https://github.com/asottile-archive/git-windows-branch-test
+ git fetch origin --tags
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 10 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.
From https://github.com/asottile-archive/git-windows-branch-test
 * [new branch]      master     -> origin/master
error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
file or directory
 ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local ref)


real-world issue: https://github.com/pre-commit/pre-commit/issues/1058

Thanks

Anthony

```

## Anthony Sottile, 2019-06-18 16:41

Subject: Re: windows: error cannot lock ref ... unable to create lock
Message-ID: <CA+dzEBniPBM9qyR9gq=8sKtc8ieUkq6HGfUuZSc5=UdovR5wkw@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEBniPBM9qyR9gq%3D8sKtc8ieUkq6HGfUuZSc5%3DUdovR5wkw%40mail.gmail.com
In-Reply-To: <CA+dzEB=iOsfuZQ5Z8uXO+k6E3WczkLX64yWUpTm1NZBjdd47kg@mail.gmail.com>

```
hit send too quickly, here's my version information:

$ git --version
git version 2.22.0.windows.1

On Tue, Jun 18, 2019 at 9:38 AM Anthony Sottile <asottile@umich.edu> wrote:
>
> I've set up a demo problematic repository on github:
> https://github.com/asottile-archive/git-windows-branch-test
>
> The minimal reproduction is:
>
> rm -rf x
> git init x
> cd x
> git remote add origin https://github.com/asottile-archive/git-windows-branch-te>
> git fetch origin --tags
>
> Here's the output:
>
> + git init x
> Initialized empty Git repository in C:/Users/IEUser/x/x/.git/
> + cd x
> + git remote add origin
> https://github.com/asottile-archive/git-windows-branch-test
> + git fetch origin --tags
> remote: Enumerating objects: 10, done.
> remote: Counting objects: 100% (10/10), done.
> remote: Compressing objects: 100% (4/4), done.
> remote: Total 10 (delta 0), reused 0 (delta 0), pack-reused 0
> Unpacking objects: 100% (10/10), done.
> From https://github.com/asottile-archive/git-windows-branch-test
>  * [new branch]      master     -> origin/master
> error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
> 'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
> file or directory
>  ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local ref)
>
>
> real-world issue: https://github.com/pre-commit/pre-commit/issues/1058
>
> Thanks
>
> Anthony

```

## Eric Sunshine, 2019-06-18 17:01

Subject: Re: windows: error cannot lock ref ... unable to create lock
Message-ID: <CAPig+cTFfhBz+xiq6VAMNOW4OTvByHJ1g5oF=RTTh_buA+nUQA@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcTFfhBz%2Bxiq6VAMNOW4OTvByHJ1g5oF%3DRTTh_buA%2BnUQA%40mail.gmail.com
In-Reply-To: <CA+dzEB=iOsfuZQ5Z8uXO+k6E3WczkLX64yWUpTm1NZBjdd47kg@mail.gmail.com>

```
On Tue, Jun 18, 2019 at 12:39 PM Anthony Sottile <asottile@umich.edu> wrote:
> + git fetch origin --tags
> Unpacking objects: 100% (10/10), done.
> From https://github.com/asottile-archive/git-windows-branch-test
>  * [new branch]      master     -> origin/master
> error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
> 'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
> file or directory
>  ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local ref)

AUX is a reserved[1] filename on Windows. Quoting from that source:

    Do not use the following reserved names for the name of a file:
    CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7,
    COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and
    LPT9. Also avoid these names followed immediately by an
    extension...

The default Git "ref store" is filesystem-based, so a branch named
"aux" is problematic. Other ref store implementations would not be
subject to this limitation (though I'm not sure what the state of the
others is -- someone with more knowledge can probably answer that).

[1]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#naming-conventions

```

## Anthony Sottile, 2019-06-18 17:19

Subject: Re: windows: error cannot lock ref ... unable to create lock
Message-ID: <CA+dzEBk5GbkuDde6nDw+nx1wL50zoswNE74EFvYJvrxPs7OZmA@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BdzEBk5GbkuDde6nDw%2Bnx1wL50zoswNE74EFvYJvrxPs7OZmA%40mail.gmail.com
In-Reply-To: <CAPig+cTFfhBz+xiq6VAMNOW4OTvByHJ1g5oF=RTTh_buA+nUQA@mail.gmail.com>

```
On Tue, Jun 18, 2019 at 10:01 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Tue, Jun 18, 2019 at 12:39 PM Anthony Sottile <asottile@umich.edu> wrote:
> > + git fetch origin --tags
> > Unpacking objects: 100% (10/10), done.
> > From https://github.com/asottile-archive/git-windows-branch-test
> >  * [new branch]      master     -> origin/master
> > error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
> > 'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
> > file or directory
> >  ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local ref)
>
> AUX is a reserved[1] filename on Windows. Quoting from that source:
>
>     Do not use the following reserved names for the name of a file:
>     CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7,
>     COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and
>     LPT9. Also avoid these names followed immediately by an
>     extension...
>
> The default Git "ref store" is filesystem-based, so a branch named
> "aux" is problematic. Other ref store implementations would not be
> subject to this limitation (though I'm not sure what the state of the
> others is -- someone with more knowledge can probably answer that).
>
> [1]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#naming-conventions

Oh of course, totally forgot about the special files on windows.

Thanks for the quick response and helpful link!

Anthony

```

## Philip Oakley, 2019-06-22 11:24

Subject: Re: windows: error cannot lock ref ... unable to create lock
Message-ID: <98e1e1e5-c410-caf1-0e2f-9cb0cc6d7e94@iee.org>
URL: https://gitlist.dev/e/98e1e1e5-c410-caf1-0e2f-9cb0cc6d7e94%40iee.org
In-Reply-To: <CAPig+cTFfhBz+xiq6VAMNOW4OTvByHJ1g5oF=RTTh_buA+nUQA@mail.gmail.com>

```
On 18/06/2019 18:01, Eric Sunshine wrote:
> On Tue, Jun 18, 2019 at 12:39 PM Anthony Sottile <asottile@umich.edu> wrote:
>> + git fetch origin --tags
>> Unpacking objects: 100% (10/10), done.
>>  From https://github.com/asottile-archive/git-windows-branch-test
>>   * [new branch]      master     -> origin/master
>> error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
>> 'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
>> file or directory
>>   ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local ref)
> AUX is a reserved[1] filename on Windows. Quoting from that source:
>
>      Do not use the following reserved names for the name of a file:
>      CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7,
>      COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and
>      LPT9. Also avoid these names followed immediately by an
>      extension...
>
> The default Git "ref store" is filesystem-based, so a branch named
> "aux" is problematic. Other ref store implementations would not be
> subject to this limitation (though I'm not sure what the state of the
> others is -- someone with more knowledge can probably answer that).
>
> [1]: https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#naming-conventions
This sounds interesting. I thought (but I'm not certain) that Git for 
Windows avoided creating files in the working tree with such problematic 
names, so that a clone of a repo that contained a file "AUX" (any case, 
any extension IIRC), would be bypassed with possibly a warning message.

However this looks to be a slightly different case where a _branch_ 
called "AUX" (lower cased) has been created within the clone, and it's a 
problem not trapped. Maybe worth creating a proper issue on the 
Git-for-Windows repo. Also cc'ing Dscho who may remember better than I.
--
Philip

```

## Johannes Schindelin, 2019-06-24 10:40

Subject: Re: windows: error cannot lock ref ... unable to create lock
Message-ID: <nycvar.QRO.7.76.6.1906241240450.44@tvgsbejvaqbjf.bet>
URL: https://gitlist.dev/e/nycvar.QRO.7.76.6.1906241240450.44%40tvgsbejvaqbjf.bet
In-Reply-To: <98e1e1e5-c410-caf1-0e2f-9cb0cc6d7e94@iee.org>

```
Hi Philip,

On Sat, 22 Jun 2019, Philip Oakley wrote:

> On 18/06/2019 18:01, Eric Sunshine wrote:
> > On Tue, Jun 18, 2019 at 12:39 PM Anthony Sottile <asottile@umich.edu> wrote:
> > > + git fetch origin --tags
> > > Unpacking objects: 100% (10/10), done.
> > >  From https://github.com/asottile-archive/git-windows-branch-test
> > >   * [new branch]      master     -> origin/master
> > > error: cannot lock ref 'refs/remotes/origin/pr/aux': Unable to create
> > > 'C:/Users/IEUser/x/x/.git/refs/remotes/origin/pr/aux.lock': No such
> > > file or directory
> > >   ! [new branch]      pr/aux     -> origin/pr/aux  (unable to update local
> > >   ref)
> > AUX is a reserved[1] filename on Windows. Quoting from that source:
> >
> >      Do not use the following reserved names for the name of a file:
> >      CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7,
> >      COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and
> >      LPT9. Also avoid these names followed immediately by an
> >      extension...
> >
> > The default Git "ref store" is filesystem-based, so a branch named
> > "aux" is problematic. Other ref store implementations would not be
> > subject to this limitation (though I'm not sure what the state of the
> > others is -- someone with more knowledge can probably answer that).
> >
> > [1]:
> > https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#naming-conventions
> This sounds interesting. I thought (but I'm not certain) that Git for Windows
> avoided creating files in the working tree with such problematic names, so
> that a clone of a repo that contained a file "AUX" (any case, any extension
> IIRC), would be bypassed with possibly a warning message.
>
> However this looks to be a slightly different case where a _branch_ called
> "AUX" (lower cased) has been created within the clone, and it's a problem not
> trapped. Maybe worth creating a proper issue on the Git-for-Windows repo. Also
> cc'ing Dscho who may remember better than I.

He doesn't ;-)

Ciao,
Dscho


```
