3

In our semester group we are using eclipse as an IDE for developing a Compiler. The issue is when it comes to git. Which files are okay to be ignored and which are crucial. It works fine on my computer, but when it is synced with git and another member from the group is trying to use the workspace, there always seem to be some errors about main not showing or a package is wrong.

Bottom line: What is okay, and what is not okay to include in .gitignore file, so that every group member is able to compile the project?

Aleksandr M
  • 24,264
  • 12
  • 69
  • 143
darophi
  • 456
  • 5
  • 15
  • 1
    Definitely *don't* ignore `.classpath` and `.project` files. See http://stackoverflow.com/q/10301845/639520 and http://stackoverflow.com/a/31256840/639520 – E-Riz Mar 31 '16 at 12:36
  • @E-Riz There are different versions of eclipse, you know. Which may have different thought of what should be in these fails. Plus there are plugins also. – Aleksandr M Mar 31 '16 at 12:44
  • Ignore all IDE files. - http://stackoverflow.com/q/14558450/1700321. – Aleksandr M Mar 31 '16 at 12:50
  • @AleksandrM, different versions of Eclipse don't matter, for the most part. Those files (and sometimes others, depending on the type of project) are designed and intended to be shared. The answer you reference is simply naive - tools like Maven or Gradle generating IDE files is a silly idea. Those are build tools, not IDE tools; they do a poor job in many cases and certainly don't account for much of what is intended to be shared as far as Eclipse project configuration. – E-Riz Mar 31 '16 at 13:35
  • @E-Riz Agree that build tools shouldn't generate ide files, but ide should be able to import existing code to its project. If we are talking about Eclipse then: Version/Implementation of Eclipse platform matters. Eclipse handles very badly errors in these conf files. Latest versions do pretty good job of importing maven projects, for example. – Aleksandr M Mar 31 '16 at 13:47

2 Answers2

4

I think the best solution is to generate .gitignore for yourself by gitignore.io.

Just choose tools that you used.

1

It depends on your requirement. Usually Compiled source,Packages, Logs and databases, Eclipse specific files/directories are removed from git push. Also can keep configuration in separate(property) file.It is easy to place project in a different environment.

This is a sample gitignore file

# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so

# Packages #
############
# it's better to unpack these files and commit the raw source
# git has its own built in compression methods
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar
*.tar
*.zip

# Logs and databases #
######################
*.log

# OS generated files #
######################
.DS_Store*
ehthumbs.db
Icon?
Thumbs.db

# Editor Files #
################
*~
*.swp

# Gradle Files #
################
.gradle
.m2

# Build output directies #
##########################
/target
*/target
/build
*/build

# IntelliJ specific files/directories #
#######################################
out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml

# Eclipse specific files/directories #
######################################
.classpath
.project
.settings
.metadata

# NetBeans specific files/directories #
#######################################
.nbattrs
samith kumarasingha
  • 294
  • 1
  • 3
  • 16
  • As far as i have understood the files .classpath and .project are important? – darophi Mar 31 '16 at 12:49
  • `.metadata` is not part of a normal Eclipse project, so no reason to list it (it's part of the workspace, so never shared anyway). Ignoring `.project` and `.classpath` means that every developer has to configure the project manually (or use flaky maven/gradle plugins to generate it). Ignoring `.settings` means you can not have many consistent rules such as code formatting and error/warning settings. Eclipse strongly recommends checking all those in to be shared with all developers. – E-Riz Mar 31 '16 at 13:39