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

Re: Beginner problem with .gitignore

From
Kai Schlamp <schlamp@gmx.de>
Date
Apr 21, 2009, 12:26 UTC
Message-ID
<gske1o$bnf$1@ger.gmane.org>
In-Reply-To
<49EDB167.1030600@drmicha.warpmail.net>
  > The problem is the recursive way in which git applies those patterns.
Show 6 quoted lines
> Your patterns above mean that git never recurses into the subdirs.
> 
> In the example above, you probably want
> 
> /a_dir/b_dir/*
> !/a_dir/b_dir/c_dir/

Ok, I see. But that way would not ignore other directories in a_dir beside b_dir. For that task I have to use the following in .gitignore:

/a_dir/* !/a_dir/b_dir/ /a_dir/b_dir/* !/a_dir/b_dir/c_dir/

This tends to a quite bloated .gitignore when you have a deep directory structure and don't want to ignore all subfolders. I also took a brief look into Mercurial and in my opinion the .hgignore is more straightforward. It seems to use regexp on the complete file path to find out if the files that should be ignored. So the above four lines can be combined to one (and if the directory structure would be deeper, it would also be just a one liner). I know that there for sure is a reason for why git uses it's pattern in .gitignore (probably a performance thing). But it would be nice to have at least an option that it recurses into subdiretories, or uses regexp syntax on the whole file path. Just my two cents.

Best regards, Kai

Previous: Michael J Gruber
Message 5 of 5 in “Beginner problem with .gitignore”
  1. Kai SchlampApr 20, 2009
  2. Michael J GruberApr 21, 2009
  3. Kai SchlampApr 21, 2009
  4. Michael J GruberApr 21, 2009
  5. Kai SchlampApr 21, 2009

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.