This is my sample Maven Dynamic Web Project in Eclipse (maven-archetype-webapp).
Which folders shall be excluded from git (that is added to .gitignore)?
I used to think that target folder in Maven means compiled .class files and is never needed to be committed/pushed - so I thought of adding entire target/
to .gitignore - because I don't want maven-fetched jars in git repo. But the problem is that then it would ignore my index.jsp (and other jsp/html files to be added) and web.xml !!!
Besides target folder contains MyListener.java, not MyListener.class!
And target folder does not contain Student.java or Student.class (this class is used inside MyListener.java with Spring ClassPathXmlApplicationContext as Student student = (Student) context.getBean("student");
)
P.S. The contents of Deployed Resources
folder is this:
There are just two subdirectories of this structure: src and target.
The target directory is used to house all output of the build.
P.S. I added target to .gitignore and the project was safely cloned and built on another machine! So - solved!
As the docs say, in the target directory are class files, jars and other output files. They are automatically generated and would only spam commits.
Since that, you shoud add the target
directory to your .gitignore
[Tip]
Use gitignore.io for generating your .gitignore