.gitignore 白名单 vim 文件夹

.gitignore whitelisting vim folder

我正在 vcshmr 的帮助下跟踪我的点文件并对其进行版本控制。按照建议,我让 vcsh 创建一个预定义的 .gitignore-file 来忽略我的 .vim- 目录之外不需要的文件。 但是,现在我想修改它,这样它就不会忽略我的 .vimrc 或我的 ~/.vim 文件夹及其所有子目录。

目前我的.gitignore的内容是这样的:

*
!/.gitignore.d
!/.gitignore.d/vim
!/.vimrc
!/.vim/
!/.vim/**

然而,它仍然忽略 vim 文件夹的所有子文件夹,尽管 .gitignore 的最后一行。我不知道为什么。你呢?

However, it still ignores all subfolders of the vim-folder, despite the last line of the .gitignore. I have no idea why. Do you?

如本 this type of .gitignore pattern i.e. * in the first line, will make git to track only those files, which you will explicitly say to track using ! opertor. Please go through that 中所述,我已详细说明。它属于它的第三点,即

  1. 带斜杠和特殊字符的模式 (*/?) :如果模式像您给出的第一个示例那样结束,images/*.* 它有效如 documentation

    中指定

    Example: "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html".

因此 git 将仅跟踪 images/ 下的文件 vim/ 而不是其子文件夹。如果您想添加所有子文件夹,请将所有文件夹添加到 .gitignore 文件中或避免使用这种 gitignore 模式 *.