Ignore files with names starting with 'output'

user4302594 picture user4302594 · Nov 28, 2014 · Viewed 11.6k times · Source

I have a program that generates text files output1.txt, output2.txt, output3.txt, etc.. I want Git to ignore these files. I can't block text files, as I have some text files that shouldn't be ignored. Also, the files are dynamically generated (there is no limit to the number appearing after “output”), so can't add the file names statically. Can someone please help me with this?

PS. I've checked out this Make .gitignore ignore everything except a few files, but it refers to a set of files alread known. In my case it might be a long list.

Answer

Ry- picture Ry- · Nov 28, 2014

Pattern matching doesn’t just work before the extension. Just as much as you can ignore *.txt, you can ignore:

output*.txt