git 对 Grails .gitignore 的建议

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/470833/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:33:29  来源:igfitidea点击:

Suggestions for Grails .gitignore

gitgrails

提问by James Allman

So far i've collected the following:

到目前为止,我已经收集了以下内容:

*.iws
*.war
.classpath
.DS_Store
.project
.settings
/*.launch
/*.tmproj
/out/**
stacktrace.log
test/reports

Any other suggestions?

还有其他建议吗?

采纳答案by VonC

Update 5 years later (April 2014):

5 年后更新(2014 年 4 月):

As mentioned in the other answers below, two sites are now able to provide good default .gitignore files, including for a Grails project.

正如下面的其他答案中提到的,两个站点现在能够提供良好的默认 .gitignore 文件,包括 Grails 项目。



(Original answer, January 2009)

(原答案,2009 年 1 月)

Only may be to add /web-app/WEB-INFto your list:here is an full exampleof such a gitignore file.

只能添加/web-app/WEB-INF到您的列表中:这是此类 gitignore 文件的完整示例

# .gitignore for Grails 1.0.3

# web application files that are overwritten by "grails upgrade"
#  cf. GRAILS_HOME/scripts/Upgrade.groovy, target( upgrade )
/web-app/WEB-INF

# IDE support files that are overwritten by "grails upgrade"
#  cf. GRAILS_HOME/scripts/CreateApp.groovy, target( createIDESupportFiles )
# to be specific, you could replace "/*" below with your project name,
#  e.g. "foobar.launch" (no slash)
.classpath
.project
.settings
/*.launch
/*.tmproj

# logs
stacktrace.log
/test/reports

# project release file
*.war


Note, as mentionned here, that :

请注意,正如这里提到的那样:

  • build.xmlis not part of that list, since grails won't overwrite it.
  • the eclipse dot files .classpath, .project, and .settingswill also not be overwritten if they exist, but they can be ignored at first.
  • for previous version of Grail, you would also have needed (at least) a line /plugins/core
  • build.xml不是该列表的一部分,因为 grails 不会覆盖它。
  • eclipse dot 文件.classpath, .project, 和.settings如果它们存在也不会被覆盖,但它们一开始可以被忽略。
  • 对于先前版本的 Grail,您还需要(至少)一行 /plugins/core

回答by Du?an Rychnovsky

You can have the .gitignore file automatically generated by Grails using the following command:

您可以使用以下命令让 Grails 自动生成 .gitignore 文件:

grails integrate-with  --git

Grails 2.1.0 generated the following file content on my machine:

Grails 2.1.0 在我的机器上生成了以下文件内容:

*.iws
*Db.properties
*Db.script
.settings
stacktrace.log
/*.zip
/plugin.xml
/*.log
/*DB.*
/cobertura.ser
.DS_Store
/target/
/out/
/web-app/plugins
/web-app/WEB-INF/classes

回答by Pieter

IMHO, stuff like .DS_Store and *.tmproj should not be in the projects .gitignore, but rather in your own userwide ignore-file, as they aren't related to the project but just related to how youwork in the repository.

恕我直言,像 .DS_Store 和 *.tmproj 这样的东西不应该在项目 .gitignore 中,而应该在你自己的用户范围 ignore-file 中,因为它们与项目无关,而只与在存储库中的工作方式有关。

Otherwise, an argument could be made to also include ignores for temporary files from Eclipse, vim, emacs, XCode, ...

否则,可以提出一个论点,包括对来自 Eclipse、vim、emacs、XCode 的临时文件的忽略……

回答by Ann Addicks

I'm very late to the game, but I came across this link for templates https://github.com/github/gitignorewhich has one for grails: https://github.com/github/gitignore/blob/master/Grails.gitignore. Hope it may be useful to anyone else who finds this page first by searching "git ignore for grails"

我玩游戏已经很晚了,但是我遇到了这个模板链接https://github.com/github/gitignore,其中有一个用于 grails:https: //github.com/github/gitignore/blob/master/ Grails.gitignore。希望它对通过搜索“git ignore for grails”首先找到此页面的其他人有用

回答by Enrico Susatyo

If you're using Intelli J IDEA should also add these:

如果您使用 Intelli J IDEA 还应该添加这些:

.idea
*.iml
*.iws
*.ipr

回答by Benny Neugebauer

Heroku also provides proposals for a .gitgnorefile (Getting Started with Grails on Heroku):

Heroku 还为.gitgnore文件提供了建议(Heroku 上的 Grails 入门):

*.iws
*Db.properties
*Db.script
.settings
.classpath
.project
eclipse
stacktrace.log
target
/plugins
/web-app/plugins
/web-app/WEB-INF/classes
web-app/WEB-INF/tld/c.tld
web-app/WEB-INF/tld/fmt.tld

We should bear all the suggestions from this thread together and create a common file. When working with the NetBeans IDE, then there are also some files that can be excluded (for example, the nbprojectsfolder).

我们应该共同承担该线程中的所有建议并创建一个公共文件。使用 NetBeans IDE 时,还可以排除一些文件(例如,nbprojects文件夹)。