What should be the content of the .gitignore file for a java project in netbeans?
3 Answers
# NetBeans specific #
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
# Class Files #
*.class
# Package Files #
*.jar
*.war
*.ear
4 Comments
.gitignore for NetBeans, it isn't quite correct. See stackoverflow.com/q/24139478/421049 .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.
4 Comments
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.
.DS_Storeas this is generated by OS X, in most directories, and is superfluous to your application.