忽略将特定目录提交到 git
Ignore committing a specific directory to git
我知道在 .gitignore 文件中给出文件或目录的路径不会将这些文件添加到我的 git 存储库中,但我想忽略所有 "build" 在我的存储库中创建的目录,我不想每次都指定我的个人构建目录的完整路径。请提出解决方案。
如果你所有的目标目录都叫"build",那么你可以在gitingnore中这样写:
[Bb]uild/
这应该可以解决问题。来自文档:
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in Git).
我知道在 .gitignore 文件中给出文件或目录的路径不会将这些文件添加到我的 git 存储库中,但我想忽略所有 "build" 在我的存储库中创建的目录,我不想每次都指定我的个人构建目录的完整路径。请提出解决方案。
如果你所有的目标目录都叫"build",那么你可以在gitingnore中这样写:
[Bb]uild/
这应该可以解决问题。来自文档:
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in Git).