Hakim
Hakim

Reputation: 3437

What to put under Source Control in a Java Project

I'm quite new to Git (Svn) and Java.

I want to put my Java Project (eventually a Java Web project) into source control, but I guess that some files doesn't have to be commited like .class files & web.xml for example.

So, what are files to commit (Servlets & JSPs), and how do I do to ignore other files, in an eclipse project? Do I need to use .gitignore file?

Upvotes: 0

Views: 1177

Answers (3)

Eugene Ryzhikov
Eugene Ryzhikov

Reputation: 17359

There is a really good project on GitHub: a collection of useful .gitignore templates:

https://github.com/github/gitignore

Upvotes: 1

Mike Thomsen
Mike Thomsen

Reputation: 37506

Assuming it's something like a typical maven structure, this is how we do it:

1) cd $PROJECT
2) git init
3) git add pom.xml
4) git add src
5) echo 'target' > .gitignore
6) git commit -m "First commit"

Upvotes: 2

Juned Ahsan
Juned Ahsan

Reputation: 68715

Source control is/should be used to put the source and resources files in it. You should avoid putting the .class or any project settings file in source control. Class files are generated as per the latest source, you should put the build file in source control to help with that. Any project/environment related settings should not be pushed to source control as each person using that source may have different environment settings.

web.xml is a resource file and should be put in source control. All other resources such as config files can also go in your repository.

Upvotes: 1

Related Questions