Maven project - explicit ignore /target folder is necessary?


I'm still not getting how IntelliJ deals with various types of directories when using git. I think it should be doing the things just right without any additional settings. In Maven project even so. Shouldn't be the /target folder git ignored by default when usin Maven? I'm pretty happy with commiting .idea folder in my personal project, so I don't need to exclude it from git. However I still need .gitignore in the project's root with just one line - /target/ - which seems strange to me. Do I really need that .gitignore file or is it possible to exclude the /target from git somewhere else in the IntelliJ settings? Or am I missing some pom.xml setting? Thank you.


Note that indication of the excluded directory in IDE means that this directory is excluded from IDE analysis/indexing, not excluding from version control.

The git uses .gitignore to determine which directories are excluded from the version control. IDE uses git to manage the files under VCS. So all such configuration should be set via the .gitignore file.