我应该把 .gitignore 放在哪里才能影响所有项目?
我应该在哪里放置 .gitignore
文件,以便我的所有项目都使用这些设置?
我尝试了各种文件夹,只有将其放入项目文件夹中才能使其正常工作,但是设置(当然)仅应用于该项目......而不是我的其他项目。
where should I place a .gitignore
file so that all my projects use those settings?
I tried various folders and I can only get it to work if I put it in my project folder, but then the settings (of course) only are applied to that project... not my other projects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
git 包含一个“全局”配置选项,可以告诉它在启动项目时包含您想要始终忽略的文件。例如,如果你的忽略文件的编译被称为:ignore_global,你可以这样做;
有关更多信息,请访问:忽略文件
git include a "global" configuration option which can tell it to include the files you want to ignore always when you start a project. Example, if the compilation of your ignore files is called: ignore_global, you could do this;
more about it at here: Ignore Files
即使以前的解决方案有效,我还是建议使用全局
~/.gitignore_global
并使用以下命令将其添加到排除文件中:git config --global core.excludesfile ~/.gitignore_global
。这是 github 推荐的解决方案: https://help.github.com/articles/ignoring-文件/
Even though the previous solutions work, I would recommend having a global
~/.gitignore_global
and adding it to your exclude files with the command:git config --global core.excludesfile ~/.gitignore_global
.This is the recommended solution by github: https://help.github.com/articles/ignoring-files/
您需要使用命令行。原因是,您需要将 gitignore 文件放置在 Eclipse 项目的父目录中,但您无法在 Eclipse 工作台中看到该目录(因为 Eclipse 项目是那里的顶级实体)。
例如,您有 2 个 Eclipse 项目,它们像这样存储在存储库
\mygitrepo\project1
\mygitrepo\project2
中,然后只需在 mygitrepo 目录中添加 .gitignore 文件即可。
You need to use the command line. The reason is, that you need to place the gitignore file in the parent directory of your Eclipse projects, but you cannot see that directory in the Eclipse workbench (as Eclipse projects are top level entities there).
E.g. you have 2 Eclipse projects, which are stored like this in your repository
\mygitrepo\project1
\mygitrepo\project2
then just add the .gitignore file in the mygitrepo directory.
它不是特定于 Eclipse 的。试试这个: http://programblings.com/2008/10/22/git -全局忽略/
It is not eclipse specific. Try this: http://programblings.com/2008/10/22/git-global-ignores/
无需使用命令行。
User Settings
选项卡。Add Entry ...
并输入core.excludesfile
作为键,输入~/.gitignore
作为值~/.gitignore< /code> 并在
.gitignore
中添加所有要忽略的模式,即:
No need to use the commandline.
User Settings
tab.Add Entry ...
and entercore.excludesfile
as key and~/.gitignore
as value~/.gitignore
and add all your to-ignore-patterns inside the.gitignore
I.e: