views:

438

answers:

4

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

+2  A: 

All files you don't want to commit into your git repository.

SourceRebels
It's just that simple. I would suggest manually adding the ones you want in the repo, and then putting everything that's left in .gitignore.
Martinho Fernandes
I think the questioner knows what the gitignore file is used for...
vkraemer
Yep but this question is subjective. It depends on the common sense of project's architect. There are one or one million correct answers.
SourceRebels
+2  A: 

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

NebuSoft
+3  A: 

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.

vkraemer
+1  A: 
Jörg W Mittag
Why use .git/info/exclude rather than the projects .gitignore? What is the benifit / downside if put in .gitignore?
Andrew Burns