I would like to make sure that git ignores any log files that are created on a rotating basis. For instance
debug.log
debug.log.1
debug.log.2
debug.log.10
should all be ignored. I am currently using *.log
and *.log.[0-9]
to ignore the first 3 in the list. To capture the third, I know I could use *.log.[0-9][0-9]
. However, I'd prefer to find a one line solution that could capture all of these.
Is there a way to tell the gitignore file to match one or more digits?
Sadly but
.gitigore
use glob instead of regex for matching, which means there's not a good way to do it.Of course you can use:
But notice this will also match something like
debug.log.9abc
. If you are okay with that, I think this pattern will be enough.If you REALLY have to do it strictly, yes you have to list them all: