git 排除 vs 忽略

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10066749/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 06:44:03  来源:igfitidea点击:

git excludes vs ignores

gitgitignoregit-tower

提问by prosseek

I use Towerfor using Git in Mac. The settings in Tower has Ignores section which creates the .gitignore, but it has another section named "Excludes". And it seems like that one can use excludes with "# git ls-files --others --exclude-from=.git/info/exclude".

我使用Tower在 Mac 中使用 Git。Tower 中的设置具有创建 .gitignore 的 Ignores 部分,但它还有另一个名为“Excludes”的部分。似乎可以将排除与“# git ls-files --others --exclude-from=.git/info/exclude”一起使用。

Tower screenshot

塔截图

What Excludes is for? Why one needs excludes when gitignore is available?

什么是排除?当 gitignore 可用时,为什么需要排除?

回答by Matthew Flaschen

It's a list of files that are not in .gitignore(which can be versioned), but which you want to exclude on your machine's copy of the repo.

这是一个不在.gitignore(可以进行版本控制)中的文件列表,但您希望在您的机器的存储库副本中排除这些文件。

From the docs:

文档

Patterns which are specific to a particular repository but which do not need to be shared with other related repositories (e.g., auxiliary files that live inside the repository but are specific to one user's workflow) should go into the $GIT_DIR/info/exclude file.

特定于特定存储库但不需要与其他相关存储库共享的模式(例如,位于存储库内但特定于一个用户工作流的辅助文件)应进入 $GIT_DIR/info/exclude 文件。

Note that .git/info/exclude can not be versioned because it's in the .git directory.

请注意, .git/info/exclude 无法进行版本控制,因为它位于 .git 目录中。