Reputation: 9259
I'm read all kinds of post on this and I just can't get it to work.
in my .ignore file I have
*/[Ll]ogs/*
Although I have tried about a dozen other variations, everything short of explicitly naming the file, I still am commiting these files
new file: src/methodfitness.web/Logs/Trace.log.2012-03-15
I also had a similar problem helping a co worker exclude his web.config file but that's his problem now, I just don't want these bloody log files.
thanks,
R
Upvotes: 6
Views: 17050
Reputation: 1904
You can also use the double asterisks as described in the documentation of git-scm (git version 2.16)
e.g.
**/[Ll]ogs
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
Other consecutive asterisks are considered invalid.
Upvotes: 0
Reputation: 97285
In order to ignore all log directories (and content too) at any deep inside your working copy you just have to read gitignore man mage and adopt example of ignoring foo dir from man-page.
For .gitignore in the root plain
logs/
pattern do the trick
Upvotes: 4
Reputation: 3921
Why do you use so strange method?
To ignore all files under the src/methodfitness.web/Logs/
folder, try to add to your .gitignore file appropriate line: src/methodfitness.web/Logs/
Upvotes: 0
Reputation: 185731
The pattern */[Ll]ogs/*
will only match a logs folder that's one level depe. Yours is 3 levels deep. You also said ".ignore file", I hope you meant ".gitignore". Anyway, you can fix this in one of four ways:
Change the pattern to src/*/[Ll]ogs/*
Put the pattern */[Ll]ogs/*
into src/.gitignore
instead of your root .gitignore
Change the pattern to just [Ll]ogs/
. This will ignore any directory called "Logs" or "logs" in your entire tree. This may not be appropriate if you only want to ignore a directory of this name within your specific domain folders.
Put the pattern *
into src/methodfitness.web/Logs/.gitignore
. This will ignore all files in that folder. The benefit of this approach is git will still create the Logs
folder when doing a checkout, which may or may not be something you want to happen. If you do this, make sure to explicitly add the .gitignore
file, or it will end up ignoring itself.
On a related note, the trailing *
is unnecessary. You can indicate directories with your ignore pattern and it will skip the entire directory. The only time when you want the trailing *
is if you need to be able to un-ignore specific files (using the prefix !
syntax, e.g. !*/[Ll]ogs/goodfile.txt
)
Upvotes: 10
Reputation: 82994
You can just use [Ll]ogs/
as the ignore pattern.
Putting that pattern in the .gitignore
file in the root of your directory structure should ignore all directories called either Logs
or logs
anywhere in the directory tree.
Upvotes: 1