我想告诉git忽略例如jpg文件,而不考虑扩展名是如何编写的。
例如:
*.jpg
应该被忽略,
包括.jpg,.JPG.和.Jpg等。
那么,在不完全忽略大小写的情况下,这种操作是否可行呢?
Git ignore可以识别glob模式,因此您可以使用此功能。
*.[jJ][pP][gG]
你可以告诉git在大多数情况下忽略大小写,包括在你的.gitignore文件中。你所需要做的只是:
git config core.ignorecase true
从实际角度考虑,可能会涉及到权衡取舍。根据 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.
因此,如果您使用大小写敏感的文件系统,则可能会遇到问题。您的结果可能会有所不同。
.gitconfig
大小写不敏感,而且会影响Git的所有部分。其次,配置文件是针对每个用户或每个克隆的东西,因此它不会应用于与您共享.gitconfig
的其他共同开发人员。 - Matthieu Moy