问题
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