【发布时间】:2012-06-22 10:00:51
【问题描述】:
我想告诉 git 忽略例如jpg 文件,无论扩展名是如何编写的。
例如
*.jpg
应该忽略
.jpg、.JPG.、.JPG
等等
如果不告诉 git 完全忽略大小写,这可能吗?
【问题讨论】:
-
你想让 git 在不区分大小写的文件系统上“工作”,还是只是为了忽略目的?
我想告诉 git 忽略例如jpg 文件,无论扩展名是如何编写的。
例如
*.jpg
应该忽略
.jpg、.JPG.、.JPG
等等
如果不告诉 git 完全忽略大小写,这可能吗?
【问题讨论】:
您可以告诉 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 的其他共同开发者。
Git ignore 理解 glob 模式,所以你可以使用这个
*.[jJ][pP][gG]
【讨论】: