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

Re: [PROPOSAL] .gitignore syntax modification

From
MMaaartin <grajcar1@seznam.cz>
Date
Oct 8, 2010, 21:58 UTC
Message-ID
<loom.20101008T234354-493@post.gmane.org>
In-Reply-To
<113B4C41-ECDA-479D-A281-DF6ACDFE8FBB@sb.org>
Kevin Ballard <kevin <at> sb.org> writes:
> ... Similarly, for foo.xcodeproj packages I
> like to ignore all contained files except project.pbxproj. 
Unfortunately, .gitignore has no good way of
> matching this sort of thing at anything other than the root level. Here's an 
example of my global
Show 6 quoted lines
> ~/.gitignore file:
> 
> *.xcodeproj/*
> !*.xcodeproj/*.pbxproj
> 
> ... On any repository where this isn't the case, I have to duplicate this 
pattern into
> a .gitignore file at the right level.
You don't. You can do something like

*.xcodeproj/* !.xcodeproj/subdir_with_project .xcodeproj/subdir_with_project/* !.xcodeproj/subdir_with_project/*.pbxproj

I'm a beginner but I just stumbled upon this very problem five minutes ago.

The reason for git ignoring everything in the directory without ever looking there is efficiency. Maybe we would need something like "weak ignore" meaning ignore all matching files but traverse the directories. I'd propose the syntax

?*.xcodeproj !*.pbxproj

for this. The pattern after the question would exclude all files below *.xcodeproj but still traverse the directories there. The second pattern would re-include the *.pbxproj files.

The lower efficiency would be no problem, since this was user's choice not to use the standard pattern. You could still prevent digging too deep by using additionally something like

*.xcodeproj/*/*
Previous: Kevin BallardNext: Kevin Ballard
Message 2 of 13 in “[PROPOSAL] .gitignore syntax modification”
  1. Kevin BallardOct 8, 2010
  2. MaaartinOct 8, 2010
  3. Kevin BallardOct 9, 2010
  4. MaaartinOct 11, 2010
  5. Nguyen Thai Ngoc DuyOct 13, 2010
  6. Kevin BallardOct 13, 2010
  7. Jonathan NiederOct 13, 2010
  8. Kevin BallardOct 13, 2010
  9. Junio C HamanoOct 13, 2010
  10. Nguyen Thai Ngoc DuyOct 13, 2010
  11. Kevin BallardOct 15, 2010
  12. Nguyen Thai Ngoc DuyOct 15, 2010
  13. Kevin BallardOct 15, 2010

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.