How do I ignore file extensions in git regardless of case?

◇◆丶佛笑我妖孽 提交于 2019-11-30 13:39:34

问题


I want to tell git to ignore e.g. jpg files regardless of how the extension is written.

e.g.

*.jpg

should ignore

.jpg, .JPG., .Jpg

etc.

Is that possible without telling git to ignore case altogether?


回答1:


Git ignore understands glob pattern, so you can use this

*.[jJ][pP][gG]



回答2:


You can tell git to ignore case in most situations, including in your .gitignore files. All you need is:

git config core.ignorecase true

From a practical point of view, there may be trade-offs involved. The git-config(1) man page says:

   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.



来源:https://stackoverflow.com/questions/11116636/how-do-i-ignore-file-extensions-in-git-regardless-of-case

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!