Meaning of leading slash in `.gitignore` file

与世无争的帅哥 提交于 2019-12-02 18:52:20

This is the documentation text:

  • A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".

These are my guesses:

  • If you use an in-repository-.gitignore, the directory in which the .gitignore is located - it is not really useful to make it relative to the repository root.

    A short experiment with same-named files in the repository root and a subdirectory (and a .gitignore in this same directory) confirms this.

  • If you use an .git/info/exclude or core.excludesfile, I suppose it is relative to the repository root.

    Also this is (for info/exclude) confirmed by the same test (both tests on 1.7.3.4).

Schnouki found the right part of the documentation about this (emphasis mine):

  • [...]
  • Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the toplevel of the work tree) being overridden by those in lower level files down to the directory containing the file. These patterns match relative to the location of the .gitignore file. A project normally includes such .gitignore files in its repository, containing patterns for files generated as part of the project build.
  • [...]

One could say that this fact could have been repeated again at the later part quoted above, for clarity.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!