Git ignore file still logs

I read all kinds of posts about it, and I just can't get it to work.

in my .ignore file i have

*/[Ll]ogs/* 

Although I tried a dozen other options, all that didn’t explicitly name the file, I still commit these files

new file: src / methodfitness.web / Logs / Trace.log.2012-03-15

I also had a similar problem helping an employee exclude his web.config file, but now his problem is, I just don't want these bloody log files.

thanks,

R

+4
source share
4 answers

The template */[Ll]ogs/* will correspond only to the log folder, on which one level is deprecated. You have 3 levels. You also said ".ignore file", I hope you meant ".gitignore". In any case, you can fix this in one of four ways:

  • Change the pattern to src/*/[Ll]ogs/*

  • Place the */[Ll]ogs/* in src/.gitignore instead of the .gitignore root

  • Change the template to [Ll]ogs/ . This will ignore any directory called "Logs" or "Logs" throughout the tree. This may not be appropriate if you want to ignore the directory of that name in your specific domain folders.

  • Put the * template in src/methodfitness.web/Logs/.gitignore . This ignores all files in this folder. The advantage of this approach: git will create a Logs folder when performing a check, which may or may not be something you want. If you do, be sure to add the .gitignore file, otherwise it will ignore itself.


In the corresponding note, the final * not needed. You can specify directories with your ignore pattern, and it will skip the entire directory. The only time you want the final * to be so that you can ignore certain files (using the prefix ! Syntax, for example !*/[Ll]ogs/goodfile.txt )

+9
source

You can simply use [Ll]ogs/ as an ignore pattern.

Putting this template in a .gitignore file in the root of your directory structure should ignore all directories called Logs or Logs anywhere in the directory tree.

+1
source

Why are you using such a strange method?

To ignore all files in the src/methodfitness.web/Logs/ folder, try adding the appropriate line to your .gitignore file: src/methodfitness.web/Logs/

+1
source

To ignore all the log directories (and contents) in any one inside your working copy, you just need to read the gitignore man mage and take the example of ignoring foo dir from the man page.

For .gitignore in the root environment

 logs/ 

pattern does the trick

+1
source

Source: https://habr.com/ru/post/1401911/


All Articles