How can I create a root folder for my projects in Eclipse as recommended by EGit? - eclipse

EGit User Guide suggests making a Repository working directory to store your projects, so you can add multiple projects to one repository:
How do I do this? I tried Eclipse's Create New Folder -- it only creates subfolders for projects. I tried moving the projects into a directory I created and hitting refresh -- nothing happened, and when I closed Eclipse it lost track of the .project file. I tried creating a new working set, but it didn't seem like the same thing.
Is this even a good idea?

I do it like this:
Create a directory somewhere (e.g. ~/git/myrepo)
In the console/terminal: enter the directory you just created
Create the Git repository using git init
In Eclipse, right click on your project and select Team -> Share Project...
As repository, select ~/git/myrepo/.git
Working directory is ~/git/myrepo
Click Finish
You can also try and create the repository using the "Share" dialog as well. This is something I did not try.

I believe this screenshot comes from the Git Repositories View, not Package Explorer. So you can achieve this simply by creating your repository in a folder outside of your Eclipse workspace.

Related

Commit Folder From Local Directory to Online Using SVN

I'm completely new to subversion and I'm unsure how to add and commit a Java Project to an online repository using svn. The goal is to move the important folders in the project including the src, package, and class. I've accessed the online repo and I (assume) I have it as a working copy. When I try to svn add the local project folders however, I am told it is not a working copy. How do I fix this? Is there a way I can make my workspace be the online repo directly? Or do I just copy the folder somehow? I'm using Cygwin and Eclipse.
To add your project to svn you can do it this way:
Right click on your project and select: Team / Share Project...
Select SVN
Select Use Existing Repository Location
Browse to the location you would like your project to reside: typically .../trunk
Click OK and finish
This should have committed your project to SVN. Regarding your question about your entire workspace being the online repo. with each of your individual projects connected to SVN just like I detailed above, you will be able to commit and update your local projects into and from SVN without any issues.

Cannot move project as it overlaps... Git/Eclipse

I am trying to move a project into my git repo, using Team -> Share Project -> Git, when I select the repo the error "Cannot move project x to target location...as this location overlaps with location..."
My workspace and repo are different folders (this seems to fix it for most people).
Which version of eclipse and egit plugin are you using?
For me on Kepler Service Release 2 and Egit 3.2.0 it works if I choose:
Team->Share Project->Git
and then tickbox Use or create repository in parent folder of project BUT then select the project folder . instead of the parent ..
In my case, there was a .project file inside the git repo. I just deleted it from the terminal. Then everything works perfectly. You can't access it with the GUI which is another reason why terminal is awesome!
Tried many options but they didn't work. I've posted an answer in another similar question which is a manual way to do it which will work with any Eclipse version, here is the link: https://stackoverflow.com/a/41799215/578046
I got this error when attempting to bring in a new subproject into an existing parent project in a "split" workspace i.e. the default configuration using separate workspace and git folders.
The final workaround was different from others listed:
Delete the project from within Eclipse (choose default option: DO NOT delete on filesystem)
Use the system shell move the new subproject from the Workspace location into its proper place under the parent project in the git folder structure
In Eclipse, go to the the Git Repositories view, right-click the new project folder under Working Tree, and choose "Import Projects..." to reimport the project
Re-add the project to any Working Sets it needs to be part of
I encountered the same problem, and used the following steps to solve the problem:
1、Team --> Share Project...
2、Check Use or create repository in parent folder of project,and then Check Your project...
3、Click Create Repository
4、Click Finish
I had the same problem and realized that when i cloned the git repository i selected the "import all existing Eclipse projects after clone finishes" checkbox. So i removed my repository and cloned it again without the checkbox selected. Then i had no problem sharing a new Java project into my repository (because no .project file was created on the git folder)
I had the same problem, here's how I solved it:
Open The Git Repositories View:
Window -> Show View -> Other -> Git -> Git Repositories -> Open
Then Right Click YourRepositoryName in the Git Repositories View and Click Clean...
A Popup Window will open, Tick the .project file and Click Finish
Now when you try to use Team -> Share Project -> Git it should work.
If Clean... doesn't delete the .project file, you can also manually do it by opening the repository file system in the Git Repositories View and look for the .project file then Right Click the file and Click Delete
I just went to git folder using terminal and entered the command rm .project. The problem went away.
I had a similar error once, which was caused by the name of my folder containing spaces, e.g. "Joe Doe".
Moving the project to a place where it doesn't have any space in file path solved my problem.

How to get src folder under project-root folder in github when staging from eclipse using egit

Current scenario :
In Eclipse when we create a project, say a PyDev project named ‘SimpleGit’, the folder structure created by eclipse will be like
EclipseWorkingDirectory/SimpleGit/src/
correct?
If we add this to git using Egit, by right clicking on the project folder SimpleGit then Team>Share, The folder structure in which repo is formed like this
Parent Folder/ SimpleGit/ .git
Parent Folder/ SimpleGit/SimpleGit/src/
And when we stage it to remote github everything will come under
Username/ SimpleGit / SimpleGit / src /
So when we look in GitHub in the root project folder (Username/ SimpleGit) we can’t see the source folder. It will be under another folder ‘SimpleGit’. How we can avoid this?
What I want is , I want to get my source forlder(src) listed under the Project Root directory, when staging from an already built project in eclipse using egit. How do I do this?
I want like this:
https://github.com/nicholasbishop/blender
Not like this:
https://github.com/afilash/SimpleGit
it cannot be done using eGit - it assumes the Eclipse project structure.
But it can be accomplished by using git itself. Just create a repository under SimpleGit folder executing 'git init'. From that point on you'd have to manage your git repository by either git itself (command line) or some other UI. SourceTree works really well for me.
It is a bit late, I know, but this method perfectly works and I hope it is useful for anyone who sees this post from now on.
The procedure is the following:
First step is creating a repository on Github (through github.com)
Move to Eclipse IDE (Git Repositories view) and click "Clone a Git Repository and add the clone to this view". Doing that the project will be somewhere located on the hard disk. Usually, it is stored in C:\Users\username\git\projectName but you are able to change it. This is our local repository.
Once done, press (in Eclipse IDE) File->Import->Projects from Git->Existing local repository(Select the one you cloned before)->Import using the new project wizard->Finish->Java->Java Project->Specify project name (just below the dialog box there is a checked checkbox that says use default location, uncheck it. Here is where you have to specify the directory you chose while cloning the repository previously).->Next->Finish
It should be enough for creating the right directory structure.

How to properly use EGit with Eclipse

The only way I seem to be able to get use git in eclipse is to create a non-git project then turn that into a repository. This ends up moving the project out of the eclipse workspace on the file system. I then have to delete the project(it's still in the git repository), then import a git repository after creating a branch and clone it to get it back into the eclipse workspace.
Is there a simpler way?
I simply want to create project that is really a clone from a local repository. Essentially I have two copies on my HD but I can commit the eclipse project to the git repository. Unfortunately there has to be a better way?
To answer this question involves three steps.
Create a external (remote) repository
Share the project in a way that it remains in the workspace
Connect the project repository to the remote repository
Create a Remote Repository on Your Local Machine
Switch to the Git perspective. Click on Create a new Git Repository.
When a dialog appears select a directory where you would like your remote
repository to be. This is were your project will be pushed to. You will also
want to select the Create as a bare repository option.
That's it for this step. You should now have this repository in your EGit
repositories list.
Sharing Project within the Workspace
There are two ways to share a project so that it remains in your workspace.
1. Make the project directory a repository
2. Make the whole workspace directory a repository
The Project as a Repository
The first option option is not recommended by the Eclipse team. This issue is
described in more detail at Why is not recommended to have an Eclipse project folder as a Git repository?.
The basics of the issue are twofold:
You can't have more than one project per repository
If some thing happens to your workspace you'll lose your repository too
Issue 1 isn't solved here. Issue 2 can be solved by connecting to a remote
repository as show later.
To share the project as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click Use or create repository in parent folder of project
Select the project from the list
Click on the Create Repository button
Click the Finish button
Next you'll want to connect your newly created repository to the remote repository.
That's covered below.
The Workspace as Repository
The second options allows multiple projects to be added to your repository.
In fact any new project you create will automatically added to the repository.
Automatically adding projects can cause some issues.
One issue is that, if there are changes in multiple projects, staging
those changes can take a bit of wading through. Using a Tree presentation when
staging can simplify things.
Another more serious issue occurs when importing a git clone of a project into
the workspace. This importing will create nested repositories. Nested
repositories can cause problems
according to this post.
By default Eclipse doesn't import the git clone of the project into the workspace.
To share the workspace as a repository:
Right click on the project
Select Team -> Share Project... from the popup menu
Click on the Create button
Select your workspace as your Repository directory
Click the Finish button
Once your repository is created you may want to do a little house keeping. I suggest
adding the RemoteSystemsTempFiles project to the .gitignore file. Note: the
.metadata file is added automatically by Eclipse.
You can ignore the RemoteSystemsTempFiles by:
Switching to the EGit perspecitive
Selecting the workspace repository from the list of repositories
Select the Git Staging tab
Click on the View Menu button on the right side the the tabs toolbar
Select Presentation -> Tree menu (folders are easier to ignore form the tree view)
Right click on the RemoteSystemsTempFiles project
Select the Ignore Folder menu
Ignore other projects in the same way
Connecting to the Remote Repository
The last stage is connecting the workspace repository to the remote repository
we created earlier. Once you've switched to the EGit perspective:
Expand your workspace respository
Right click on the Remote node in the tree
Select the Create remote... menu
Leave the remote name as origin
Select Configure fetch
Press Ok
Click on the Change... button
Click on the Local File button
Select the bare repository that you created in the first section
Click Finish
Click Save and Fetch and then Ok
You can then stage, commit and push changes in your projects and workspace.
When you first commit and push EGit will push the default branch master
to the remote and configure pulling this branch from remote repository.
Follwing the User Guide, you would need to create the .git repo within your current project path:
If the .git path is within the current project path, there is no reason EGit moves your files anywhere else.

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.