What should be the content of the .gitignore file for a java project in netbeans?
There are no "files that should be" in the .gitignore file. It is simply a matter of preference of which files you wish to be ignored by the git tools. It makes it easier for you to quickly see changes in files you care about without being cluttered with additional files.
If you are curious about the formatting of what goes in a .gitignore you can read up on it here
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.