git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: refining .gitignores

From
Alex Riesen <raa.lkml@gmail.com>
Date
Nov 15, 2007, 21:17 UTC
Message-ID
<20071115211727.GC3552@steel.home>
In-Reply-To
<80ejerdzjd.fsf@tiny.isode.net>
Bruce Stephens, Thu, Nov 15, 2007 21:28:06 +0100:
Show 18 quoted lines
> Alex Riesen <raa.lkml@gmail.com> writes:
> 
> [...]
> 
> > .gitignore? Without "s"?
> 
> Yes, my mistake.  I added '*.c' to ".gitignore".
> 
> > Maybe your .c files are already added to index? Otherwise you have to
> > use the second form. It shows known-to-Git ignored files.
> 
> They are in the index.  What I want is a list of files which are known
> to git, which are matched by the default rules (in particular the
> .gitignore files).
> 
> So that should be this?
> 
>     git ls-files --exclude-per-directory=.gitignore -i

Yes, so it seems. The per-directory ignore-files don't work. "--exclude-from=" (aka -X) still does.

Show 9 quoted lines
> But that shows nothing at all, and it still shows nothing if I add a
> "builtin-add.c" as an argument to it (this file exists, and is in the
> index).
> 
> "git add builtin-add.c" fails, complaining (correctly) that the path
> is ignored by one of my .gitignore files.
> 
> We're obviously talking past one another somehow, or I have a broken
> build of git?

No, I honestly believed that Git-known files can be ignored. According to Linus I must be wrong, but I have an excuse:

    $ mkdir aaa
    $ cd aaa
    $ git init
    Initialized empty Git repository in .git/
    $ uname >abc
    $ git add .
    $ ls > .gitignore
    $ git ls-files -X .gitignore
    $ git ls-files -X .gitignore -i
    abc
Previous: Bruce StephensNext: Linus Torvalds
Message 8 of 9 in “refining .gitignores”
  1. Bruce StephensNov 14, 2007
  2. Alex RiesenNov 14, 2007
  3. Bruce StephensNov 15, 2007
  4. Alex RiesenNov 15, 2007
  5. Bruce StephensNov 15, 2007
  6. Linus TorvaldsNov 15, 2007
  7. Bruce StephensNov 15, 2007
  8. Alex RiesenNov 15, 2007
  9. Linus TorvaldsNov 15, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.