gitignore for folder of eclipse projects

只愿长相守 提交于 2019-12-24 17:24:16

问题


I am working following a set of java swing tutorials, each is an Eclipse project, keep them in a workspace. I init a git repository in the workspace folder (mac), and upload to github. When I download this folder in another computer (linux), the projects are not recognized as such, and opening/importing in Eclipse fails. Says: 'Folder not recognized as project'. What is the best way to handle a collection of projects in git?


回答1:


If you want to have all of your Eclipse project data across your machines, you will have to add the following files/folders to Git:

  • .classpath
  • .project
  • .settings (folder)

Make sure that these are not ignored in either your local or globale .gitignore files.

Ignore things like the bin and target folders, since they contain the compiled classes and shouldn't be added to Git.




回答2:


Regarding the failed import: as @nwinkler writes, Eclipse looks for the .project and .classpath files so you need to add them (and the .settings directory) to your git repository.

Regarding .gitignore, I typically put the workspace stuff there (and then do import existing projects in eclipse after cloning):

That is,

.metadata/.plugins
.metadata/.lock
.metadata/.log

and then for each project, the bin folder

project_dir/bin

and any other generated files



来源:https://stackoverflow.com/questions/30865009/gitignore-for-folder-of-eclipse-projects

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!