Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Eclipse-specific files in an VCS be ignored, if using Maven?

I know why not to commit Eclipse/IDE-specific files into a VCS like Git (which I am actually using). That is one of the reasons I am using Maven and having it generating these files for you and not having them under version control.

But I wonder, if these files should be ignored in .gitignore which itself is under control of VCS/Git:

.classpath
.project
.settings/
target/

Is this okay?

What are the pros and cons since the .gitignore file itself becomes kind of IDE-specific as the files ignored there are IDE-spefific? Any best-practice?

like image 430
SimonTheSorcerer Avatar asked Nov 17 '11 15:11

SimonTheSorcerer


2 Answers

With the team's I've worked on, the general rule has been that you don't check in anything that is generated by or obtained by Maven. Since the pom.xml contains everything you need to create the .project, .classpath, and .settings files, we don't check them in.

My .gitignore always contains .classpath, .settings, .project, and target for Maven projects.

Edit: As mentioned in my comment below, here is another suggestion: If you really want to avoid having Maven or IDE specific entries in your .gitignore, try writing your .gitignore so you list only what you DO want checked in.

*
!stuffIDoWantToCheckIn
like image 83
Lawrence McAlpin Avatar answered Oct 18 '22 10:10

Lawrence McAlpin


I'm getting my information from the following article: https://help.github.com/articles/ignoring-files

That suggests that you can create a global gitignore file (suggest under ~/.gitignore_global) containing .project, etc. As the file is outside the repo, it won't show...

You register it as a global ignore file with the following command:

git config --global core.excludesfile ~/.gitignore_global

Alternatively, you can create a per-repo untracked gitignore entries in the .git/info/exlude file

like image 33
Chanoch Avatar answered Oct 18 '22 10:10

Chanoch