Eclipse "Share Project" by hand? - eclipse

What actually happens to the file system when you do a Subclipse Share Project on an Eclipse project that was externally checked out from Subversion? All the .svn folders are already in place. I get an error when I try to Share Project the right way, and I'd rather not delete and re-checkout the projects from the SVN Repository browser.

Dunno exactly what happens within eclipse, I presume it does some funky stuff in the .metadata directory of the workspace. That said, I would recommend the following to get eclipse to learn about the svn settings of the project:
Delete the project from the workspace (keep "Delete project contents on disk" unchecked)
File > Import... > General > Existing Projects into Workspace
Browse to the folder containing the original project(s) of interest
Import the projects into your workspace
This seems to have the side effect of subclipse noticing the subversion settings when importing the "new" projects into your workspace.

The Share Project action is intended to commit the first version of a project, i.e. one with no .svn metadata in place. It will get upset if it sees .svn directories already there. As Rob wrote, the way to get that checked-out project into Eclipse is to use the import capability.

I'm not sure what version of Eclipse you are using or whether this will apply since I'm using Subversive instead of Subclipse. When I use the share project feature to commit the project into svn when I already have all of the .svn directories in place, I get a choice of like "Use current project settings" and then eclipse automatically reattaches the project svn information to the team integration. You can screw it up if you try to enter different information.

Related

Git repo outside of Eclipse workspace

(for some reason I can't log in with my old account, sorry for the unfriendly username)
I'm using Eclipse and git. There have been several discussions about having the git repository outside of the Eclipse workspace. This is one of them:
Should I store git repository in Home or Eclipse Workspace?
So, I created a repo outside the workspace, and my project files are now in the repo.
I can still see the project in Eclipse, work on the project, and generally do what I used to do, so all is well. Project Properties show that the project is in the repo and outside the workspace.
But then what's the "Eclipse Workspace" good for? What does it even mean to have an "Eclipse Workspace" ? If after all you can work wherever you like, then your entire disk is your "Eclipse Workspace" ?
Or am I missing something? Am I supposed to copy the project into the workspace and work on that copy? If it makes any difference, the idea is to have a repo on GitHub and push and pull my local stuff to/from there...
Thank you.
But then what's the "Eclipse Workspace" good for? What does it even mean to have an "Eclipse Workspace" ?
This is for project metadata, and shouldn't be confused with the actual data of your project.
Those data can be stored in a git repo anywhere on your disk.
the Eclipse project can be imported in an Eclipse workspace, for Eclipse to work with.
That is why, when you delete a project in Eclipse, you can simply "unreferenced" it form your Eclipse workspace, while keeping it on your hard drive.

Eclipse + EGit: clone project into workspace

I'm a little confused about how EGit workes.
I have an existing git repository on Github and want to clone it into my workspace.
My goal is to have the local repository directly stored inside my workspace-folder but I don't get it working with EGit.
When I want to clone the github repo with EGit, I have to choose a directory as destination. The suggested directory is in my homedir (not in my workspace). When I choose this directory I can see the project in Eclipse but it is not stored in my workspace-folder. Instead it is stored in my home dir.
When I choose a directory directly inside my workspace, later when it comes to import the project it says that there is already a directory with this name.
I don't know how to solve this. I thought this would be a common scenario. In the past I have used hgEclipse (Mercurial) and it was working exactly the way I thought it should be so I'm confused EGit doesn't. Maybe I misunderstood something.
Probably this is important to know: In the github repository there are no .project or .settings files from eclipse. I have them on my .gitignore and so in the import-dialog I have to choose "Import as General Project" and not "Import Existing Projects". But I think this shouldn't matter?
I hope someone can help me or explain me why the EGit plugin doesn't clone the repository directly into the workspace by default.
My Eclipseversion is 3.6, I have installed EGit over the markedplace.
As mentioned in this EGit tutorial, the destination directory you mention when importing (cloning) a Git repo is any directory you want, in which the .git will be created:
You don't have to select the workspace itself (at least, you should select the workspace/myproject subdirectory, in order to not make the all Eclipse workspace a Git repo.
And you can select any other directory outside the workspace: the Eclipse workspace should only contain meta-data about Eclipse projects and settings.
When declaring a new project, you will be able to select the project directory, making that directory the parent for .classpath and .project.
Your workspace will list that new project, even though it lives outside the workspace.
To import a project from GitHub you should use the Import Git Repository as New Project dialogue (right click -> Import -> Git -> Git Repository as New Project). This way you can select the destination of the clone repository, including the Workspace.
If you want to edit the sources in the IDE and also want the changes to be reflected in the Git repository, delete the original source file in the project and link the source file in the git repo to the project. That way, you can directly make changes to the git repo and you can commit them when needed. Be careful not to delete the files when deleting the project in the IDE though.
Steps to have git project in workspace (with egit):
On GIT perspective choose "Clone a Git Repository and add it to this view"
As a destination choose folder inside a workspace (for example ".../workspace/myproject")
Wait until cloned
File -> New -> Project
General -> project
As a project name type name of a folder in workspace where project has been cloned (for example "myproject")
Nope. There's no way to get this to work. You can't use egit to checkout a git project into the workspace and if you check it out elsewhere and try to copy it into the workspace, you will lose your connection to the remote repository. If you want VCS that works, use svn or mercurial.
In the "Configure Local Storage Location" dialog,
choose .../workspace/projectname.
Then in the next dialog,
we get the wizard selection menu. Normally you should select "Import existing project".
(But see below).
Finally, there is the "Import Projects" dialog.
For various unexplained reasons, sometimes this dialog is empty and won't
let you finish. In that case, you need to cancel, and then outside of Eclipse completely delete the working directory that was cloned into, and then start again.
But if there is the project there, press finish. If it complains about the project already existing, go back to the wizard menu and change it to use a wizard. Select a Java wizard and then finish. Often this will work, but only if you first got the "Import Projects" menu to recognize the project in the first place.
It may take several attempts to get this to work! But once it is set up, it works fine.
So, in summary: is is possible to get EGit to use the default project location for the git clone, but in my experience it may inexplicably require several attempts.

Associating existing Eclipse project with existing SVN repository

I have an eclipse project on my hard disk, which is a fairly recent check out from an SVN repository. I've imported this project into my Eclipse workspace, and now want to associate it with the SVN repository.
How do I do this? The only options I seem to have under Right-click -> Team is "Share Project", which only seems to allow me to do an initial import.
Edit: Motivation - It's a largish repository, and I don't really want to have to import the whole thing over the network.
Edit 2: There are (for some reason) no .svn dirs in the project. So maybe a fresh import from svn is the only option
Team->Share project is exactly what you need to do. Select SVN from the list, then click "Next". Subclipse will notice the presence of .svn directories that will ask you to confirm that the information is correct, and associate the project with subclipse.
I just wanted to add that if you don't see Team -> Share project, it's likely you have to remove the project from the workspace before importing it back in. This is what happened to me, and I had to remove and readd it to the workspace for it to fix itself. (This happened when moving from dramatically different Eclipse versions + plugins using the same workspace.)
subclipse not showing "share project" option on project context menu in eclipse
I'm asked this question very frequently, if it's smart to use "Share project..." if a eclipse project has been disconnected from it SVN counterpart in the repository. So, I append my answer to this thread.
The SVN-Team option "Share project ..." is totally fine for projects that exist in SVN and in your Eclipse workspace, even if the Eclipse project is missing the hidden .svn configuration. You can still connect them. Eclipse SVN-implementation (Subclipse/Subversive) will verify if the provided SVN http(s) source is populated. If yes, all existing files will be copied and linked (checked out in SVN terms) to your very personal Eclipse workspace.
Word of caution:
Do a backup if you depend on you local files. The SVN implementation may vary its behaviour with every release.
If you have multiple projects encapsulated within each other, make sure you point the SVN path to the correct local path.
regards,
Feder
I came across the same issue. I checked out using Tortoise client and then tried to import the projects in Eclipse using import wizard. Eclipse did not recognize the svn location. I tried share option as mentioned in the above posts and it tried to commit these projects into SVN. But my issue was a version mismatch. I selected svn 1.8 version in eclipse (I was using 1.7 in eclipse and 1.8.8 in tortoise) and then re imported the projects. It resolved with no issues.
I am using Tortoise SVN client. You can alternativley check out the required project from SVN in some folder. You can see a .SVN folder inside the project. Copy the .SVN folder into the workspace folder. Now remove the project from eclipse and import the same again into eclipse. You can see now the project is now associated with svn
In case of SVN servers you have to creating a central repository with all projects. The contents of the repository can be uploaded with the Team/Share command; in case of the Subversive client it automatically runs a commit after the import, so you can upload your files.
This step cannot be circumvented in any way using a centralized version management system such as SVN.
Try this- Close the project then open it. It links with svn automatically,if project was checked out from valid svn path.

What should be committed to the repository in the Eclipse workspace?

I have a Eclipse installed to work with BIRT reports. What files in the workspace should be committed to the repository and what files should not?
Basically, any file able to help a developer checkout the repo and (almost) immediately open the project to work on it.
That should include at least eclipse files like .project, .classpath, and some IDE settings.
They might be some BIRT-specific settings as well.
See also:
Do you keep your project files under version control?
When working with Eclipse, should I add the workspace to the source control?

How to import an already checked out svn repository into Eclipse?

I have a Subversion repository I have checked out and have in my local hard disk. Now, how do I import this into Eclipse?
When I choose File > Import and choose SVN, there is only an option to checkout a project from the server again. File > New project seems to be for projects we are creating new projects from scratch.
"Import..." the existing project then "Share..." the project. The Subversive (or SubClipse) client will realize that the project has a .svn folder and reattach to the repository.
In Eclipse click on:
File -> Import -> General -> Existing Projects into Workspace
However you have to define a workspace location being different from the one that is being checked out in order to prevent yourself from changes to the checked out repository.
I've tried with File->Import Projects from File System or Archive, and in the blank space of Import source, you just need to browse through button Directory.. and find the project path you wanted to import. Then the svn connection is automatically detected.
Install the subversive plugin from market place or from update site.
Use appropriate SVN connectors during setup Windows->Preferances->Team->SVN->SVNConnectors. SVNKit 1.8.11 worked for me.
Make sure Enable automatic project share checkbox is set at this location Windows->Preferances->Team->SVN->General
Just import the existing SVN project File->Import->General->Existing Projects into Workspace, then eclipse will automatically recognize it based on the .svn hidden folder. Need not explicitly do Team->Share project.