什么时候使用.git/info/exclude而不是〜/.gitignore(core.excludesFile)来排除文件? [英] When would you use .git/info/exclude instead of ~/.gitignore (core.excludesFile) to exclude files?

查看:135
本文介绍了什么时候使用.git/info/exclude而不是〜/.gitignore(core.excludesFile)来排除文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于何时使用.git/info/exclude而不是~/.gitignore (core.excludesFile)排除文件,我有点困惑.我很清楚何时使用项目存储库中存在的.gitignore文件,该文件特定于该项目,版本控制并通过克隆与其他存储库共享,但是我无法理解上述两个用户特定文件之间的区别,可以忽略.

I am little bit confused as to when would you use .git/info/exclude instead of ~/.gitignore (core.excludesFile) to exclude files? I am clear when to use .gitignore file present in project repository which is specific to that project, version-controlled and shared with other repo via clone but I am unable to understand difference between the above two somewhat user specific files to be ignored.

因此,我要查找的是~/.gitignore.git/info/exclude之间的区别,而不是.gitignore (project dir).git/info/exclude之间的区别.

Thus, I am looking for difference between ~/.gitignore and .git/info/exclude and not between .gitignore (project dir) and .git/info/exclude.

更新:我无法想到.git/info/exclude的特定用法,因为我要忽略的任何文件都属于.gitignore~/.gitignore.如果有人可以提供一个示例/文件,该示例应专门包含在.git/info/exclude中,则将确实有帮助.

UPDATE: I am unable to think specific usage of .git/info/exclude as whatever files I want to ignore either fall in .gitignore or ~/.gitignore. It would really help if somebody can give an example for pattern/file that should specifically be included in .git/info/exclude.

推荐答案

在全局忽略文件(~/.gitignore$XDG_CONFIG_HOME/git/ignore)中放置文件名或模式将抑制所有存储库中对此文件的抱怨.在每个存储库忽略文件(.git/info/exclude)中放置相同的名称或模式将仅抑制对该存储库的投诉.

Placing a file name or pattern in your global ignore file (~/.gitignore or $XDG_CONFIG_HOME/git/ignore) will suppress complaints about it in all repositories. Placing the same name or pattern in the per-repository ignore file (.git/info/exclude) will suppress complaints only for that one repository.

这些都不是天生的优劣.他们只是不同.值得注意的是,古老的Git仅支持存储库中的.gitignore.git/info/exclude文件,即不支持每个用户的全局~/.gitignore.

Neither of these is inherently superior or inferior; they're just different. It's worth noting that ancient Git supported only the in-repository .gitignore and .git/info/exclude files, i.e., had no per-user, global ~/.gitignore.

如果您亲自使用编辑器来制作名称以(例如)$而不是.bak.~结尾的备份文件,而其他所有人都没有(并且其他人的备份文件已经在已提交的.gitignore),则可以将*$放入您的个人~/.gitignore中.如果仅将此编辑器与此项目一起使用,则将其放在.git/info/exclude中可能更有意义.

If you personally use an editor that makes backup files whose name ends with (say) $ instead of .bak or .~, and everyone else doesn't (and the everyone-else's backup files are already in a committed .gitignore), you might put *$ in your personal ~/.gitignore. If you only use this editor with this one project, it might make more sense to put this in .git/info/exclude.

如果项目本身制作了许多将被忽略的文件,则将这些名称放入提交到项目中的.gitignore文件中是有意义的,但是如果出于某些原因该不能完成,然后将这些模式放入.git/info/exclude是有意义的:在其他项目中不应忽略它们.

If the project itself makes a lot of to-be-ignored files, it makes sense to put these names into .gitignore files that are committed into the project, but if there is some reason that this cannot be done, it then makes sense to put these patterns into .git/info/exclude: they should not be ignored in other projects.

这篇关于什么时候使用.git/info/exclude而不是〜/.gitignore(core.excludesFile)来排除文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆