# git ls-files -o seems to ignore .gitignore

4 messages from 2014-10-27 to 2014-10-27. Participants: Richard PALO, Charles Bailey, Matthieu Moy, richard.palo@free.fr.
Thread: https://gitlist.dev/t/37819

## Richard PALO, 2014-10-27 06:16

Subject: git ls-files -o seems to ignore .gitignore
Message-ID: <544DE351.9060800@netbsd.org>
URL: https://gitlist.dev/e/544DE351.9060800%40netbsd.org

```
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm having an issue in that 'git ls-files -o' seems to ignore
[parts of] .gitignore whereas other commands, such as 'git status'
seem fine.

Here is an example:
> richard@omnis:/home/richard/src/pkgsrc$ export LANG=C 
> richard@omnis:/home/richard/src/pkgsrc$ git --version git version
> 2.1.2 richard@omnis:/home/richard/src/pkgsrc$ cat .gitignore 
> pkgchk*.conf* .#* README*.html 
> richard@omnis:/home/richard/src/pkgsrc$ git status On branch dev
> 
> It took 6.82 seconds to enumerate untracked files. 'status -uno' 
> may speed it up, but you have to be careful not to forget to add 
> new files yourself (see 'git help status'). nothing to commit,
> working directory clean richard@omnis:/home/richard/src/pkgsrc$ git
> ls-files -o |grep -c README 12393

Known issue?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJUTeNRAAoJECAB22fHtp27hckH+wdDHV3oZqatSIqNdhUCUxsJ
jR8tZpQxoKfV944aPBgH4/CXkCtFFSvnGKfH+plij+Y5ggZwfDQ3lXIg1qOsH3qj
9mvudRuFxwujXfFSTHdReqQxFT8p3roZjB0GdwoiFeBIsQ8CLfGjxfQZDQU18i3/
IfR682UbzuiR6kodhD5oX/I2S5l5dRRuabQq5t2zJL9BHmGleLaBgOjnne7T26PC
JpNMt+60J93J9VzBN9kQABAO5BMUE4mN6g2141N9JXlMsg6DSGHPN5vQD7t7IxE1
mtNX9iMrjFa1Hsm2neXqvjb95ZGbZwTnxFcI7To6P3V/+v9QMpKrrBWu/AFNdF0=
=84q1
-----END PGP SIGNATURE-----

```

## Charles Bailey, 2014-10-27 06:47

Subject: Re: git ls-files -o seems to ignore .gitignore
Message-ID: <20141027064747.GA7773@hashpling.org>
URL: https://gitlist.dev/e/20141027064747.GA7773%40hashpling.org
In-Reply-To: <544DE351.9060800@netbsd.org>

```
On Mon, Oct 27, 2014 at 07:16:49AM +0100, Richard PALO wrote:
> Hash: SHA1
> 
> I'm having an issue in that 'git ls-files -o' seems to ignore
> [parts of] .gitignore whereas other commands, such as 'git status'
> seem fine.

This is, as far as I am aware, by design. If you want to apply the
standard ignore rules to the output of ls-files -o then you can use the
--exclude-standard option.

```

## Matthieu Moy, 2014-10-27 08:31

Subject: Re: git ls-files -o seems to ignore .gitignore
Message-ID: <vpq8uk1lxqb.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpq8uk1lxqb.fsf%40anie.imag.fr
In-Reply-To: <20141027064747.GA7773@hashpling.org>

```
Charles Bailey <charles@hashpling.org> writes:

> On Mon, Oct 27, 2014 at 07:16:49AM +0100, Richard PALO wrote:
>> Hash: SHA1
>> 
>> I'm having an issue in that 'git ls-files -o' seems to ignore
>> [parts of] .gitignore whereas other commands, such as 'git status'
>> seem fine.
>
> This is, as far as I am aware, by design.

I would not call that "by design", but indeed "git ls" was written this
way, and it's a plumbing command for which we do not want
backward-incompatible changes. So, --exclude-standard is available, but
not activated by default.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## richard.palo@free.fr, 2014-10-27 09:22

Subject: Re: git ls-files -o seems to ignore .gitignore
Message-ID: <391421950.105620016.1414401723677.JavaMail.root@zimbra7-e1.priv.proxad.net>
URL: https://gitlist.dev/e/391421950.105620016.1414401723677.JavaMail.root%40zimbra7-e1.priv.proxad.net
In-Reply-To: <vpq8uk1lxqb.fsf@anie.imag.fr>

```
Well, ok.  Not very intuitive, so I added an alias in .gitconfig... 
'ls = ls-files --exclude-standard' and that seems to work now alright for me.

Thanks

----- Mail original -----
> De: "Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>
> À: "Charles Bailey" <charles@hashpling.org>
> Cc: "Richard PALO" <richard@netbsd.org>, git@vger.kernel.org
> Envoyé: Lundi 27 Octobre 2014 09:31:56
> Objet: Re: git ls-files -o seems to ignore .gitignore
> 
> Charles Bailey <charles@hashpling.org> writes:
> 
> > On Mon, Oct 27, 2014 at 07:16:49AM +0100, Richard PALO wrote:
> >> Hash: SHA1
> >> 
> >> I'm having an issue in that 'git ls-files -o' seems to ignore
> >> [parts of] .gitignore whereas other commands, such as 'git status'
> >> seem fine.
> >
> > This is, as far as I am aware, by design.
> 
> I would not call that "by design", but indeed "git ls" was written
> this
> way, and it's a plumbing command for which we do not want
> backward-incompatible changes. So, --exclude-standard is available,
> but
> not activated by default.
> 
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
> 

```
