如果使用Maven,VCS中的特定于Eclipse的文件是否应该被忽略? [英] Should Eclipse-specific files in an VCS be ignored, if using Maven?

查看:129
本文介绍了如果使用Maven,VCS中的特定于Eclipse的文件是否应该被忽略?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道为什么不将Eclipse / IDE特定的文件提交到像Git这样的VCS(我正在使用它)。这是我使用Maven的原因之一,让它为你生成这些文件,不是让它们在版本控制下。



但是我奇怪的是,如果这些文件应该在VCS / Git控制下的.gitignore中忽略:

  .classpath 
.project
.settings /
target /

这样好吗? / p>

自从.gitignore文件本身变成IDE特定类型之后,有什么优点和缺点?任何最佳做法?

解决方案

随着团队的工作,一般的规则是,你不检查在由Maven生成或获得的任何内容中。由于pom.xml包含了创建.project,.classpath和.settings文件所需的一切,因此我们不检查它们。



我的.gitignore总是包含.classpath,.settings,.project和Maven项目的目标。



编辑:正如我在下面的评论中提到的,这里是另一个建议:如果你真的想避免在你的.gitignore中使用Maven或IDE特定条目,尝试编写你的.gitignore,以便只列出你想要签入的内容

  * 
!stuffIDoWantToCheckIn


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?

解决方案

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

这篇关于如果使用Maven,VCS中的特定于Eclipse的文件是否应该被忽略?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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