git netbeans java 项目的 .gitignore 文件中应该有什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2586097/
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
what should be in .gitignore file for a netbeans java project?
提问by thuaso
What should be the content of the .gitignore file for a java project in netbeans?
netbeans 中 java 项目的 .gitignore 文件的内容应该是什么?
采纳答案by vkraemer
There are a fair number of files that you probably do not need to commit into git, since they are built, are generated by NB or contain environment specific information.
有相当多的文件您可能不需要提交到 git 中,因为它们是构建的、由 NB 生成的或包含特定于环境的信息。
If you create a project that uses Ant as the build mechanism, you usually end up with a directory tree that looks like this...
如果您创建一个使用 Ant 作为构建机制的项目,您通常会得到一个如下所示的目录树......
project-root-directory/
+ nbproject/
build-impl.xml
+ private/
+ project.properties
+ project.xml
+ src/
+ test/
+ build.xml
After you do a build.. there will be a couple additional directories
在你构建之后.. 会有几个额外的目录
project-root-directory/
+ build/
+ dist/
+ nbproject/
build-impl.xml
+ private/
+ project.properties
+ project.xml
+ src/
+ test/
+ build.xml
You should probably put the build, dist and nbproject/private directories (and their children) into your .gitignore.
您可能应该将 build、dist 和 nbproject/private 目录(及其子目录)放入您的 .gitignore 中。
If you want to be very aggressive about excluding files, you may want to consider excluding all the files that appear in nbproject EXCEPT project.properties and project.xml. The other files in the nbproject directory are regenerated by NetBeans when the project is opened.
如果您想非常积极地排除文件,您可能需要考虑排除出现在 nbproject EXCEPT project.properties 和 project.xml 中的所有文件。当项目打开时,NetBeans 会重新生成 nbproject 目录中的其他文件。
回答by mono68
# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
# Class Files #
*.class
# Package Files #
*.jar
*.war
*.ear
回答by J?rg W Mittag
There should be no NetBeans-specific files in your .gitignore
. The .gitignore
file is project-specific but shared between developers, IOW there should only be things in there that are commonfor all developers working with the code (including ones that use OSX, Linux instead of Windows and Eclipse, IntelliJ or Notepad as editors) and that are specificto the project.
您的.gitignore
. 该.gitignore
文件是特定于项目的,但在开发人员之间共享,IOW 中应该只有所有使用代码的开发人员通用的内容(包括使用 OSX、Linux 而不是 Windows 和 Eclipse、IntelliJ 或记事本作为编辑器的开发人员)和是特定于项目的。
If there are some files that you would like to ignore based on your specific environment (like e.g. Windows Thumbs.db
and desktop
files or NeBeans nbproject
directories) you should do that in your global ignore list, not in the project-specific .gitignore
– if only because then you don't need to add them to every single of your projects individually.
如果您想根据您的特定环境(例如 WindowsThumbs.db
和desktop
文件或 NeBeansnbproject
目录)忽略某些文件,您应该在全局忽略列表中执行此操作,而不是在特定于项目的列表中执行此操作.gitignore
——如果只是因为您不这样做'不需要将它们单独添加到您的每个项目中。
If the files you want to ignore are both specific to your environment and specific to the project, put them into that repository's .git/info/exclude
.
如果您要忽略的文件既特定于您的环境又特定于项目,请将它们放入该存储库的.git/info/exclude
.