Accidentally overwrote .classpath file when exporting project on eclipse? - eclipse

I've been pushing and pulling projects from git and importing them into my eclipse workspace.
I tried exporting my project and I got an error (something about overwriting .classpath file) and I chose to proceed.Now I can't open my project(class path not in class file error) and I can't push anything into gitlab anymore because they will notify no changes have been made even if I modified the code.
What my Eclipse workspace looks like:
I googled, apparently you can re-generate .classpath files? If it helps I did save a copy of the overwritten .classpath file.

Related

Eclipse Oxygen - Git Staging NOT Showing File Under Dot Folder

I have a project in Eclipse Oxygen that uses Git. When a file is created or edited it shows in the Unstaged Changes list on the Git Staging View. This allows you to drag the file to the Staged Changes list and then it can be committed.
I needed to create a folder named .sti directly under the project folder and then a folder named bin under that, like this:
project/.sti/bin
Then I had to create a file called assemble in the .stl/bin folder.
The problem is that the file called assemble does NOT show in the Unstaged Changes list. Therefore I cannot stage and commit it.
Is there any way of getting this file to appear?
I'm sure that the .sti folder is the cause of the problem.
Any ideas or help would be much appreciated...
In the end I deleted the .gitignore file in the project folder and recreated it. Upon refreshing the project in Project Explorer, the changed file appeared in the Unstaged Changes.
This was rather strange as the original .gitignore did not specify: .sti

gitignore for folder of eclipse projects

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?
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.
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

Eclipse deleting project but not the source code

Is there a way to delete an Eclipse project while preserving all the resources? (i.e. source code, etc.).
I guess I could delete the following files from the project directory manually:
.cproject
.project
But I am concerned that my Eclipse .metadata information that lives in my workspace may still look for those files and get confused if I delete the project files manually.
What I usually do is remove the project using eclipse (do not delete project contents on disk) and remove any .* eclipse-related file that could stay.
With the checkout unchecked, it deletes the project informations while preserving the source code.

What files should be committed to github for an eclipse project

What files should I commit to github so that its a valid Eclipse project ?
I am just committing my source files and packages but when I try to re-create the project I receive this error 'no projects found' :
I think I need to also commit the .project file ?
You need to commit your:
.settings dir
.classpath file
.project file
The better idea will be to use maven for your project so that
you will have a common configuration for all the IDEs (eclipse, netbeans, ideaj ...) and no need to push your eclipse specific configuration.
For a typical Java SE Eclipse project, you must commit .project and .classpath files, but not necessary .settings folder. I tested this scenario by committing one project from my windows environment and cloning that onto my Linux environment; Eclipse imported and run this project without any error. Hope this tip helps you reduce committing one folder (the .setting).

Ignore .classpath file while sync CVS in eclipse

I know that you can ignore the file (preference-team-ignore resources) type while committing to CVS from eclipse however how can I ignore the file type being synchronized with CVS. I have got 40 project in workspeace and every time I sync with CVS, it list all the .classpath files from all the project however I would like to ignore this file to make CVS sync view better.
any help will be appreciated.
Cheers
You can add the .classpath file to the .cvsignore file. In Eclipse, you should be able to right click on the .classpath file and go to Team -> Add to .cvsignore. Here are some additional details.