# Git pathspecs difference in behavior between linux (wsl) and windows

8 messages from 2021-05-13 to 2021-05-13. Participants: Alexandre Remy, Johannes Sixt, Junio C Hamano.
Thread: https://gitlist.dev/t/55682

## Alexandre Remy, 2021-05-13 06:57

Subject: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <CAKToE5BnzXd_2pjhJY13E=e6b1ZgOV=NmXr_WfpCQd+LxXsO3A@mail.gmail.com>
URL: https://gitlist.dev/e/CAKToE5BnzXd_2pjhJY13E%3De6b1ZgOV%3DNmXr_WfpCQd%2BLxXsO3A%40mail.gmail.com

```
Hi,

I do not understand why the same command works on linux and not on
windows. Is the pathspecs syntax differ or there is a problem on the
git windows version?

* On windows (git version 2.31.1.windows.1)

git status -- 'src/test.js'
On branch master
nothing to commit, working tree clean


* On linux (wsl: git version 2.25.1)

git status -- 'src/test.js'
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   src/test.js
A classic git status gives the same result between linux and windows
(with correct file detected).

Regards,

```

## Johannes Sixt, 2021-05-13 07:49

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <81d06db6-fd91-7ec5-6aa5-84f69a227204@kdbg.org>
URL: https://gitlist.dev/e/81d06db6-fd91-7ec5-6aa5-84f69a227204%40kdbg.org
In-Reply-To: <CAKToE5BnzXd_2pjhJY13E=e6b1ZgOV=NmXr_WfpCQd+LxXsO3A@mail.gmail.com>

```
Am 13.05.21 um 08:57 schrieb Alexandre Remy:
> Hi,
> 
> I do not understand why the same command works on linux and not on
> windows. Is the pathspecs syntax differ or there is a problem on the
> git windows version?
> 
> * On windows (git version 2.31.1.windows.1)
> 
> git status -- 'src/test.js'
> On branch master
> nothing to commit, working tree clean
> 
> 
> * On linux (wsl: git version 2.25.1)
> 
> git status -- 'src/test.js'
> On branch master
> Changes not staged for commit:
>   (use "git add <file>..." to update what will be committed)
>   (use "git restore <file>..." to discard changes in working directory)
>         modified:   src/test.js
> A classic git status gives the same result between linux and windows
> (with correct file detected).

Which shell did you use to invoke the Windows version? If it was from
CMD or PowerShell, then you must not put the name in single-quotes:

   git status -- src/test.js

The reason is that the single-quote does not have a special meaning for
CMD and PowerShell like it does for a POSIX shell.

-- Hannes

```

## Alexandre Remy, 2021-05-13 08:05

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <CAKToE5DgtW1Kuw4AE5+Am_=9gATN-S=xk1kYXMZUWvtdtNy_PQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKToE5DgtW1Kuw4AE5%2BAm_%3D9gATN-S%3Dxk1kYXMZUWvtdtNy_PQ%40mail.gmail.com
In-Reply-To: <81d06db6-fd91-7ec5-6aa5-84f69a227204@kdbg.org>

```
Thank you, that was that. I was misled by the doc and the single-quote
which indeed is specific to the linux platform.

Thank you again for your prompt reply.

Le jeu. 13 mai 2021 à 09:49, Johannes Sixt <j6t@kdbg.org> a écrit :
>
> Am 13.05.21 um 08:57 schrieb Alexandre Remy:
> > Hi,
> >
> > I do not understand why the same command works on linux and not on
> > windows. Is the pathspecs syntax differ or there is a problem on the
> > git windows version?
> >
> > * On windows (git version 2.31.1.windows.1)
> >
> > git status -- 'src/test.js'
> > On branch master
> > nothing to commit, working tree clean
> >
> >
> > * On linux (wsl: git version 2.25.1)
> >
> > git status -- 'src/test.js'
> > On branch master
> > Changes not staged for commit:
> >   (use "git add <file>..." to update what will be committed)
> >   (use "git restore <file>..." to discard changes in working directory)
> >         modified:   src/test.js
> > A classic git status gives the same result between linux and windows
> > (with correct file detected).
>
> Which shell did you use to invoke the Windows version? If it was from
> CMD or PowerShell, then you must not put the name in single-quotes:
>
>    git status -- src/test.js
>
> The reason is that the single-quote does not have a special meaning for
> CMD and PowerShell like it does for a POSIX shell.
>
> -- Hannes

```

## Alexandre Remy, 2021-05-13 09:31

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <CAKToE5DEL1ZFwUbvcC-M3y-3mSVsVgMXDig4G=jcKbc-nJ_GnQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKToE5DEL1ZFwUbvcC-M3y-3mSVsVgMXDig4G%3DjcKbc-nJ_GnQ%40mail.gmail.com
In-Reply-To: <CAKToE5DgtW1Kuw4AE5+Am_=9gATN-S=xk1kYXMZUWvtdtNy_PQ@mail.gmail.com>

```
I have an additional question, does double-quotes be safely used in
both windows (that's ok) and linux shell  for pathspecs (git status --
"src/test.js") in case of spaces in the path?

Le jeu. 13 mai 2021 à 10:05, Alexandre Remy
<alexandre.remy.contact@gmail.com> a écrit :
>
> Thank you, that was that. I was misled by the doc and the single-quote
> which indeed is specific to the linux platform.
>
> Thank you again for your prompt reply.
>
> Le jeu. 13 mai 2021 à 09:49, Johannes Sixt <j6t@kdbg.org> a écrit :
> >
> > Am 13.05.21 um 08:57 schrieb Alexandre Remy:
> > > Hi,
> > >
> > > I do not understand why the same command works on linux and not on
> > > windows. Is the pathspecs syntax differ or there is a problem on the
> > > git windows version?
> > >
> > > * On windows (git version 2.31.1.windows.1)
> > >
> > > git status -- 'src/test.js'
> > > On branch master
> > > nothing to commit, working tree clean
> > >
> > >
> > > * On linux (wsl: git version 2.25.1)
> > >
> > > git status -- 'src/test.js'
> > > On branch master
> > > Changes not staged for commit:
> > >   (use "git add <file>..." to update what will be committed)
> > >   (use "git restore <file>..." to discard changes in working directory)
> > >         modified:   src/test.js
> > > A classic git status gives the same result between linux and windows
> > > (with correct file detected).
> >
> > Which shell did you use to invoke the Windows version? If it was from
> > CMD or PowerShell, then you must not put the name in single-quotes:
> >
> >    git status -- src/test.js
> >
> > The reason is that the single-quote does not have a special meaning for
> > CMD and PowerShell like it does for a POSIX shell.
> >
> > -- Hannes

```

## Johannes Sixt, 2021-05-13 13:02

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <68a4ebd3-3c80-8983-9a26-f205debc4b5b@kdbg.org>
URL: https://gitlist.dev/e/68a4ebd3-3c80-8983-9a26-f205debc4b5b%40kdbg.org
In-Reply-To: <CAKToE5DEL1ZFwUbvcC-M3y-3mSVsVgMXDig4G=jcKbc-nJ_GnQ@mail.gmail.com>

```
Am 13.05.21 um 11:31 schrieb Alexandre Remy:
> I have an additional question, does double-quotes be safely used in
> both windows (that's ok) and linux shell  for pathspecs (git status --
> "src/test.js") in case of spaces in the path?

They can be used in both POSIX shell and Windows CMD and, I would
assume, also in the PowerShell. Note though, that there are subtle
differences when other special characters occur between double-quotes,
notably the backslash. Please use your favorite search engine to learn more.

-- Hannes

```

## Junio C Hamano, 2021-05-13 20:08

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <xmqqeeeabdml.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqeeeabdml.fsf%40gitster.g
In-Reply-To: <68a4ebd3-3c80-8983-9a26-f205debc4b5b@kdbg.org>

```
Johannes Sixt <j6t@kdbg.org> writes:

> Am 13.05.21 um 11:31 schrieb Alexandre Remy:
>> I have an additional question, does double-quotes be safely used in
>> both windows (that's ok) and linux shell  for pathspecs (git status --
>> "src/test.js") in case of spaces in the path?
>
> They can be used in both POSIX shell and Windows CMD and, I would
> assume, also in the PowerShell. Note though, that there are subtle
> differences when other special characters occur between double-quotes,
> notably the backslash. Please use your favorite search engine to learn more.

And a dollar sign, in addition to the backslash?

```

## Johannes Sixt, 2021-05-13 21:03

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <dbf1e10c-c43c-3293-61b7-eff5fceecb84@kdbg.org>
URL: https://gitlist.dev/e/dbf1e10c-c43c-3293-61b7-eff5fceecb84%40kdbg.org
In-Reply-To: <xmqqeeeabdml.fsf@gitster.g>

```
Am 13.05.21 um 22:08 schrieb Junio C Hamano:
> Johannes Sixt <j6t@kdbg.org> writes:
> 
>> Am 13.05.21 um 11:31 schrieb Alexandre Remy:
>>> I have an additional question, does double-quotes be safely used in
>>> both windows (that's ok) and linux shell  for pathspecs (git status --
>>> "src/test.js") in case of spaces in the path?
>>
>> They can be used in both POSIX shell and Windows CMD and, I would
>> assume, also in the PowerShell. Note though, that there are subtle
>> differences when other special characters occur between double-quotes,
>> notably the backslash. Please use your favorite search engine to learn more.
> 
> And a dollar sign, in addition to the backslash?

Granted, there's not a subtle, but a big difference how the dollar sign
is treated ;) but I don't want to write a tutorial here. Hence, my hint
towards a search engine.

-- Hannes

```

## Alexandre Remy, 2021-05-13 21:17

Subject: Re: Git pathspecs difference in behavior between linux (wsl) and windows
Message-ID: <CAKToE5B7xsNiXV2U4gRJeqEke9Y3gPpFfBwAtBPrvBx4jAx3VQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAKToE5B7xsNiXV2U4gRJeqEke9Y3gPpFfBwAtBPrvBx4jAx3VQ%40mail.gmail.com
In-Reply-To: <dbf1e10c-c43c-3293-61b7-eff5fceecb84@kdbg.org>

```
Yep, I know, no problem. The primary subject is closed. thank you.

Le jeu. 13 mai 2021 à 23:03, Johannes Sixt <j6t@kdbg.org> a écrit :
>
> Am 13.05.21 um 22:08 schrieb Junio C Hamano:
> > Johannes Sixt <j6t@kdbg.org> writes:
> >
> >> Am 13.05.21 um 11:31 schrieb Alexandre Remy:
> >>> I have an additional question, does double-quotes be safely used in
> >>> both windows (that's ok) and linux shell  for pathspecs (git status --
> >>> "src/test.js") in case of spaces in the path?
> >>
> >> They can be used in both POSIX shell and Windows CMD and, I would
> >> assume, also in the PowerShell. Note though, that there are subtle
> >> differences when other special characters occur between double-quotes,
> >> notably the backslash. Please use your favorite search engine to learn more.
> >
> > And a dollar sign, in addition to the backslash?
>
> Granted, there's not a subtle, but a big difference how the dollar sign
> is treated ;) but I don't want to write a tutorial here. Hence, my hint
> towards a search engine.
>
> -- Hannes

```
