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

后端 未结 2 1299
萌比男神i
萌比男神i 2020-12-29 18:54

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

e.g.

*.jpg

should ignore

相关标签:
2条回答
  • 2020-12-29 19:33

    Git ignore understands glob pattern, so you can use this

    *.[jJ][pP][gG]
    
    0 讨论(0)
  • 2020-12-29 19:33

    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.

    0 讨论(0)
提交回复
热议问题