where should I put .gitignore to affect all projects?

无人久伴 提交于 2019-12-10 23:16:45

问题


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.


回答1:


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.




回答2:


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;

git config --global core.excludesfile /path/to/your/ignore_global

more about it at here: Ignore Files




回答3:


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/




回答4:


It is not eclipse specific. Try this: http://programblings.com/2008/10/22/git-global-ignores/



来源:https://stackoverflow.com/questions/9415726/where-should-i-put-gitignore-to-affect-all-projects

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!