你什么时候会使用 .git/info/exclude 而不是 ~/.gitignore (core.excludesFile) 来排除文件?
When would you use .git/info/exclude instead of ~/.gitignore (core.excludesFile) to exclude files?
我有点困惑,您什么时候会使用 .git/info/exclude
而不是 ~/.gitignore (core.excludesFile)
来排除文件?我很清楚何时使用项目存储库中存在的 .gitignore
文件,该文件特定于该项目,受版本控制并通过克隆与其他存储库共享,但我无法理解上述两个用户特定文件之间的区别忽略。
因此,我正在寻找 ~/.gitignore
和 .git/info/exclude
之间的区别,而不是 .gitignore (project dir)
和 .git/info/exclude
之间的区别。
更新:我想不出 .git/info/exclude
的具体用法,因为我想忽略的任何文件都属于 .gitignore
或 ~/.gitignore
。如果有人可以给出一个应该特别包含在 .git/info/exclude
.
中的 pattern/file 的例子,那将会很有帮助
来自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.
Patterns which a user wants Git to ignore in all situations (e.g.,
backup or temporary files generated by the user’s editor of choice)
generally go into a file specified by core.excludesFile in the user’s
~/.gitconfig.
如果您在 IDE 上工作,它通常有 IDE 个特定文件,例如项目设置、工作区设置等。这些文件是用户和存储库(不同 IDE不同的项目...)具体。可以使用 $GIT_DIR/info/exclude
文件排除此类文件。
关于这个~/.gitconfig
,编辑器可能会在编辑过程中在目录中留下一些备份或临时文件,例如nano keeping swap files,因此对于本地系统中的所有存储库,这些文件应该被全局忽略.
Still the question remains; is it safe to assume that .gitignore and
~/.gitignore is sufficient to specify what should be ignored?
.gitignore
应该不是问题,因为它是特定于存储库的,但是 ~/.gitignore
可能是个问题,请考虑使用 ~/.gitingore
全局忽略文件的情况本地存储库,事实证明该文件是另一个存储库的必要组件,在这种情况下,应该使用 $GIT_DIR/info/exclude
。
在全局忽略文件(~/.gitignore
或 $XDG_CONFIG_HOME/git/ignore
)中放置一个文件名或模式将抑制所有存储库中的投诉。在每个存储库忽略文件 (.git/info/exclude
) 中放置相同的名称或模式将仅抑制对该存储库的投诉。
这些都没有天生的优劣之分;它们只是不同。值得注意的是,古老的 Git 仅支持存储库中的 .gitignore
和 .git/info/exclude
文件,即没有针对每个用户的全局 ~/.gitignore
.
如果您个人使用的编辑器制作的备份文件的名称以(例如)$
而不是 .bak
或 .~
结尾,而其他人则不这样做(并且每个人的备份文件都已经提交 .gitignore
),您可以将 *$
放入您的个人 ~/.gitignore
。如果你只在这个项目中使用这个编辑器,把它放在 .git/info/exclude
.
中可能更有意义
如果项目本身产生了很多被忽略的文件,将这些名称放入提交到项目中的 .gitignore
文件中是有意义的,但是如果有某种原因,这个 不能完成,然后将这些模式放入.git/info/exclude
中是有意义的:在其他项目中不应忽略它们。
我有点困惑,您什么时候会使用 .git/info/exclude
而不是 ~/.gitignore (core.excludesFile)
来排除文件?我很清楚何时使用项目存储库中存在的 .gitignore
文件,该文件特定于该项目,受版本控制并通过克隆与其他存储库共享,但我无法理解上述两个用户特定文件之间的区别忽略。
因此,我正在寻找 ~/.gitignore
和 .git/info/exclude
之间的区别,而不是 .gitignore (project dir)
和 .git/info/exclude
之间的区别。
更新:我想不出 .git/info/exclude
的具体用法,因为我想忽略的任何文件都属于 .gitignore
或 ~/.gitignore
。如果有人可以给出一个应该特别包含在 .git/info/exclude
.
来自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.
Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig.
如果您在 IDE 上工作,它通常有 IDE 个特定文件,例如项目设置、工作区设置等。这些文件是用户和存储库(不同 IDE不同的项目...)具体。可以使用 $GIT_DIR/info/exclude
文件排除此类文件。
关于这个~/.gitconfig
,编辑器可能会在编辑过程中在目录中留下一些备份或临时文件,例如nano keeping swap files,因此对于本地系统中的所有存储库,这些文件应该被全局忽略.
Still the question remains; is it safe to assume that .gitignore and ~/.gitignore is sufficient to specify what should be ignored?
.gitignore
应该不是问题,因为它是特定于存储库的,但是 ~/.gitignore
可能是个问题,请考虑使用 ~/.gitingore
全局忽略文件的情况本地存储库,事实证明该文件是另一个存储库的必要组件,在这种情况下,应该使用 $GIT_DIR/info/exclude
。
在全局忽略文件(~/.gitignore
或 $XDG_CONFIG_HOME/git/ignore
)中放置一个文件名或模式将抑制所有存储库中的投诉。在每个存储库忽略文件 (.git/info/exclude
) 中放置相同的名称或模式将仅抑制对该存储库的投诉。
这些都没有天生的优劣之分;它们只是不同。值得注意的是,古老的 Git 仅支持存储库中的 .gitignore
和 .git/info/exclude
文件,即没有针对每个用户的全局 ~/.gitignore
.
如果您个人使用的编辑器制作的备份文件的名称以(例如)$
而不是 .bak
或 .~
结尾,而其他人则不这样做(并且每个人的备份文件都已经提交 .gitignore
),您可以将 *$
放入您的个人 ~/.gitignore
。如果你只在这个项目中使用这个编辑器,把它放在 .git/info/exclude
.
如果项目本身产生了很多被忽略的文件,将这些名称放入提交到项目中的 .gitignore
文件中是有意义的,但是如果有某种原因,这个 不能完成,然后将这些模式放入.git/info/exclude
中是有意义的:在其他项目中不应忽略它们。