Netbeans java 项目的 .gitignore 文件中应该包含什么?

发布于 2024-08-27 20:24:11 字数 50 浏览 6 评论 0原文

netbeans 中的 java 项目的 .gitignore 文件的内容应该是什么?

What should be the content of the .gitignore file for a java project in netbeans?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

陌若浮生 2024-09-03 20:24:11
# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# Class Files #
*.class

# Package Files #
*.jar
*.war
*.ear
# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

# Class Files #
*.class

# Package Files #
*.jar
*.war
*.ear
你的呼吸 2024-09-03 20:24:11

有相当多的文件您可能不需要提交到 git 中,因为它们是构建的、由 NB 生成的或包含环境特定信息。

如果你创建一个使用 Ant 作为构建机制的项目,你通常会得到一个看起来像这样的目录树...

project-root-directory/
+ nbproject/
  build-impl.xml
  + private/
  + project.properties
  + project.xml
+ src/
+ test/
+ build.xml

在你完成构建之后..将会有几个额外的目录

project-root-directory/
+ build/
+ dist/
+ nbproject/
  build-impl.xml
  + private/
  + project.properties
  + project.xml
+ src/
+ test/
+ build.xml

你可能应该把 build, dist和 nbproject/private 目录(及其子目录)到您的 .gitignore 中。

如果您想要非常积极地排除文件,则可能需要考虑排除 nbproject 中出现的所有文件(除了project.properties 和project.xml)。 nbproject 目录中的其他文件在项目打开时由 NetBeans 重新生成。

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.

If you create a project that uses Ant as the build mechanism, you usually end up with a directory tree that looks like this...

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.

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.

寂寞笑我太脆弱 2024-09-03 20:24:11

.gitignore 中不应有特定于 NetBeans 的文件。 .gitignore 文件是特定于项目的,但在开发人员之间共享,IOW,其中应该只包含所有使用代码的开发人员(包括使用代码的开发人员)共同的内容OSX、Linux(而不是 Windows)和 Eclipse、IntelliJ 或记事本作为编辑器)并且特定于项目。

如果您希望根据您的特定环境忽略某些文件(例如 Windows Thumbs.dbdesktop 文件或 NeBeans nbproject目录)您应该在全局忽略列表中执行此操作,而不是在特定于项目的 .gitignore   - 如果只是因为这样您就不需要将它们单独添加到每个项目中。

如果您要忽略的文件既特定于您的环境又特定于项目,请将它们放入该存储库的 .git/info/exclude 中。

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 common for 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 specific to the project.

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.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文