Git ignore: how to match one or more digits

I would like to make sure git ignores any log files created based on rotation. For instance,

debug.log
debug.log.1
debug.log.2
debug.log.10

should be ignored. I am currently using *.logand *.log.[0-9]to ignore the first 3 on the list. To capture the third, I know what I can use *.log.[0-9][0-9]. However, I would prefer to find a one-liner solution that could capture all of this.

Is it possible to specify a gitignore file to match one or more digits?

+4
source share
1 answer

, .gitigore glob , , .

Git , fnmatch (3) FNM_PATHNAME...

, :

*.log.[0-9]*

, debug.log.9abc. , , .

, , :

*.log
*.log.[0-9]
*.log.[0-9][0-9]
*.log.[0-9][0-9][0-9]
# ... And so on if needed.
+8

All Articles