Thread (5 messages) flat view 5 messages, 2 authors, 2016-06-15

Re: Beginner problem with .gitignore

From: Kai Schlamp <hidden>
Date: 2016-06-15 22:46:38

  > The problem is the recursive way in which git applies those patterns.
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help