Git ignore: How to match one or more digits

耗尽温柔 提交于 2019-11-30 13:30:33

Sadly but .gitigore use glob instead of regex for matching, which means there's not a good way to do it.

Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag ...

Of course you can use:

*.log.[0-9]*

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:

*.log
*.log.[0-9]
*.log.[0-9][0-9]
*.log.[0-9][0-9][0-9]
# ... And so on if needed.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!