Ignore files with names starting with 'output'

I have a program that generates text files output1.txt , output2.txt , output3.txt , etc. I want Git to ignore these files. I cannot block text files since I have text files that cannot be ignored. In addition, files are dynamically generated (there is no limit on the number that appears after the "output"), so you cannot add file names statically. Can someone please help me with this?

PS. I checked this Make .gitignore to ignore everything except a few files , but this applies to a set of known files. In my case, it could be a long list.

+5
source share
3 answers

Pattern matching does not work before extension. Just as you can ignore *.txt , you can ignore:

 output*.txt 
+9
source

Just add the following to your gitignore:

 output*.txt 

* is a "wildcard", so it will match any.

+1
source

Using * is exactly the same as when matching regular expressions (or wildcards) will do the job. Just enter a record

  output * .txt 
to your .gitignore file and the problem is resolved!
+1
source

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


All Articles