无论大小写,如何忽略 git 中的文件扩展名?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11116636/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I ignore file extensions in git regardless of case?
提问by Joseph Tura
I want to tell git to ignore e.g. jpg files regardless of how the extension is written.
我想告诉 git 忽略例如 jpg 文件,无论扩展名是如何编写的。
e.g.
例如
*.jpg
*.jpg
should ignore
应该忽略
.jpg, .JPG., .Jpg
.jpg、.JPG.、.Jpg
etc.
等等。
Is that possible without telling git to ignore case altogether?
如果不告诉 git 完全忽略大小写,这可能吗?
回答by CharlesB
Git ignore understands glob pattern, so you can use this
Git ignore 理解 glob 模式,所以你可以使用它
*.[jJ][pP][gG]
回答by Todd A. Jacobs
You can tell git to ignore case in most situations, including in your .gitignore files. All you need is:
您可以告诉 git 在大多数情况下忽略大小写,包括在您的 .gitignore 文件中。所有你需要的是:
git config core.ignorecase true
From a practical point of view, there may be trade-offs involved. The git-config(1) man page says:
从实际的角度来看,可能需要权衡取舍。git-config(1) 手册页说:
core.ignorecase
If true, this option enables various workarounds to enable git to
work better on filesystems that are not case sensitive, like FAT.
For example, if a directory listing finds "makefile" when git
expects "Makefile", git will assume it is really the same file, and
continue to remember it as "Makefile".
The default is false, except git-clone(1) or git-init(1) will probe
and set core.ignorecase true if appropriate when the repository is
created.
So, you may run into trouble if you are on a case-sensitive filesystem. Your mileage may vary.
因此,如果您使用区分大小写的文件系统,您可能会遇到麻烦。你的旅费可能会改变。