无论如何,我如何忽略git中的文件扩展名?

Jos*_*ura 32 git gitignore

我想告诉git忽略例如jpg文件,无论扩展是如何编写的.

例如

*.JPG

应该忽略

.jpg,.JPG.,.jpg

等等

如果没有告诉git完全忽略案例,这可能吗?

Cha*_*esB 57

Git忽略了解glob模式,所以你可以使用它

*.[jJ][pP][gG]
Run Code Online (Sandbox Code Playgroud)


Tod*_*obs 20

在大多数情况下,您可以告诉git忽略大小写,包括在.gitignore文件中.所有你需要的是:

git config core.ignorecase true
Run Code Online (Sandbox Code Playgroud)

从实际的角度来看,可能存在权衡取舍.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.
Run Code Online (Sandbox Code Playgroud)

因此,如果您使用的是区分大小写的文件系统,则可能会遇到麻烦.你的旅费可能会改变.

  • 我不会推荐这个.首先,正如你所说,这不仅使`.gitconfig`不敏感,而且基本上都是Git.然后,配置是每用户或每克隆的事情,因此它不适用于与您共享`.gitconfig`的其他共同开发人员. (3认同)
  • 我同意@MatthieuMoy。你绝对会、肯定、肯定会后悔——但只有在调试了几个小时后为什么你的文件丢失或者为什么一切都被神秘地破坏了。如果打开,请将其关闭。 (2认同)