I'm more or less a git newbie, trying to get a good Setup to work in Eclipse with egit. I'm running Kepler with latest updates.
Originally I Setup the structure inside the Workspace Directory.
+Workspace/.git
+Workspace/TheProject
Using this Setup (admittedly with Juno) commits were taking forever. For this and other reasons I'd like to move git outside the Workspace Directory, outside eclipse in a parallel Directory.
+OtherDirectory/.git
+Workspace/TheProject
But I'm not getting very far. There seems to be no easy way to split the EXISTING git to another Location without having the Project move there too(!?)
I've tried e.g. Cloning the existing git (in the git repository perspective) and having it Import the Project in the same move.
I've tried just Cloning the existing git, without selection of "Import Project" at the same time.
Then I right clicked the cloned repository and went through the Import Existing Project dialog. I don't get a Chance to say where the Project should be loaded to.
In both cases the Project Ends up in the same Directory as the .git Directory (now outside the Workspace)
+OtherDirectory/.git
+OtherDirectory/TheProject
and not as I wish - to have the Project in the Workspace Directory.
This must be possible (?), but how?
Simply copy the .classpath and .project from Workspace/TheProject or OtherDirectory/TheProject, to otherDirectory (where the .git folder is).
Then import your project into the workspace, as in "Eclipse - Import an existing project?"
Everything will remain in OtherDirectory/ (outside your Eclipse workspace folder), but will be visible in your Eclipse workspace.
Related
I am trying to import an existing git repository as an eclipse project. The repository is stored in the location ~/src/repo_dir, and ~/src/ is my eclipse workspace directory.
If I use the sequence of menu operations:
File --> Import --> Git --> Projects from Git --> Local --> (Select my repo)
--> "Import as General Project"
I get the error:
/Users/me/src/repo_dir overlaps the location of another project: 'repo_dir'
and I can't import the project. It seems to be because Egit does not want the original repo that is being imported to already be in the workspace. However, if I then move the repo_dir out of the workspace directory ~/src/, and then import the project via the method above, it doesn't copy the contents to the workspace directory, so now my files live somewhere else, which is undesirable. The only workaround that I have found is to move the repo out of ~/src, import it, delete the resulting project, move the repo back into ~/src, and then import it with git as an 'Existing project.' Does anyone know of a cleaner way to handle this?
There are two different issues here:
Git handles a selected folder in your computer as a repository - and also stores some git-related metadata in it.
Eclipse handles a selected folder in your computer as your workspace. It stores that Eclipse configuration files (not meant to be shared), and even worse, it expects a single-level folder hierarchy for projects.
This means, putting a Git repository inside the workspace might cause a lot of unwanted issues - so I do not recommend this way (even if by some hack it is workable). However, if you want to organize all stuff related to an Eclipse workspace, you could create a folder structure as this:
eclipse-stuff
workspace
git
git-repo1
git-repo2
The workspace folder is given to Eclipse as the workspace folder, while git-repo1 and git-repo2 are your Git repositories.
On the other hand, I like to put all my git repositories into a common folder, regardless of the Eclipse workspace I use them in, but if you want to organize contents, this might not be enough for you.
Had this problem with Eclipse Kepler.
End up with installing Eclipse Mars and import the new project in another workspace.(Luna will also work fine)
If you need to work on current projects and set up environment for the coming one...
I installed EGit on Juno and created a Java project in workspace of Eclipse. Then I shared that project to Git. Then when I check the project's properties, I found that the project had been moved from its original workspace into Git local repository. When I make some changes in Eclipse editor, the changes are made on the local repository without commit.
How to isolate Eclipse workspace from git local repository?
(Well, my Eclipse workspace is ~/Documents/workspace, my git local repository is ~/git/myrepository1. )
The workspace is still in its original location outside of edit. It's the projects that have been moved into the git-controlled directories. Normally projects are created in the Eclipse workspace folder but you can override that default.
If you really want to isolate changes from git, you'll have to break git's control of the project, but you may still have to move the project contents back into your workspace. Unfortunately, the process of getting further changes back into git gets really messy.
I've found it unnerving at first the way git controls my eclipse projects, but after a while it does begin to make sense and is really a very powerful version control function.
I am new to Egit and created a new repository for a GWT project I'm working on. Unfortunately, I let it create the repository under my Dropbox folder, and now I'm regretting it because I'm syncing megabytes of temp files (e.g. *.class) over the internet. The "create repository" wizard also moved the project's files from the Eclipse workspace to a working directory under Dropbox (along with the .git folder).
What is an easy way for me to move this Egit repository and working directory to somewhere else, other than the Dropbox folder?
(btw, since I'm using Egit, the solution needs to work such that Eclipse is happy and I can keep building/using my project).
I managed to do it myself, here's how:
In Eclipse, right-click MyApp project, Refactor->Move. Move the Eclipse project to a new spot on disk. Note that I kept the .../GitRepositories/MyApp/MyApp dir structure, it's just that I moved the location of GitRepositories to a new place. Also note that this left the old dir with nothing but the .git folder inside it (i.e. Eclipse moved the working files/dirs but not the repo).
Close Eclipse
Move the .git directory from the old directory to the new. Be sure to keep it in the right relative place! I accidentally moved .git from .../GitRepositories/MyApp to .../GitRepositories/MyApp/MyApp. This screwed things up and I had to back track...
Start Eclipse
It might already work at this point, but because I moved .git to the wrong place when I first did it, I had to do the following steps:
Right-click MyApp project, Team->Disconnect
Right-click MyApp project, Team->Share Project...
The wizard automatically finds the Git report relative to the project dir: ../.git
Happy hacking...
When working with a local repository, you can just do the following:
Close Eclipse
Move the git repository on disk
Reopen Eclipse
Select File->Import... -> Git -> Projects from Git
Select local repository and add the new repository location
Select your project(s) to be added
(Optional) Remove the old project references from your workspace.
It may seem like a lot of steps, but it's actually very simple and less invasive than moving the repo and working copy separately.
Im very new to git ingeneral, egit and github.
The problem:
Lets say I have a project for eclipse in c:/username/workspace name "Test". So I versioned it and pushed it up to github.
Now I can see all my Files in github under the directory "Test" in github. In example /src. The "Test" directory is not versioned. only the name of the repository is "Test".
My next step was to delete my local files and fetch my project again(For testing). After that I had to import my project again (but I had to use the new project wizard) over the egit view. Unluckily also the wrong scala version was detected. (Was a play framework project). So I had a big exclamation mark on the project view.
My questions:
What is the best practice to oush a project to github so everyone can participate? Everything under the project folder? Obviously some information got lost through the process.
How can I prevent to generate a new project every time someone clones the repository?
What about best practices for using git inside the workspace. Eclipse warned not to put the project inside the workspace.
Im coming from a subversion background :/. Maybe a general missunderstanding.
Thanks in advance
Switching from SVN to Git in an Eclipse environment can take some getting use to. (I'm still getting accustomed to it myself.) Keep in mind the difference between the role of the .git folder and the .svn folders for Git and SVN respectively. There is a .svn folder at every folder level in the working copy. There is no .svn folder in the traditional Eclipse workspace root. The "source controlled things" are subdirectories of the workspace, not the workspace itself. This is generally good because the workspace contains desktop specific settings that one generally doesn't want shared (much of it in the .metadata directory).
With Git, there is only one .git folder that contains everything. The first impulse is to do a
git init
at the workspace level. This would make the subfolders (the Eclipse projects) eligible for source control. But wait, so is .metadata. Of course you can ignore it. But you may have to ignore lots of other folders (projects) that you do not want source controlled. Of course, the .gitignore should be included. But others will have different files to ignore.
It turns out that its easier to use Git with Eclipse if you place the .git folder and its sibling source controlled folders (Eclipse projects) someplace else besides the workspace root. Your view in Eclipse doesn't change. You still see all your projects, both the Git-controlled and the SVN controlled and ones not shared at all. But underneath in the filesystem, the Git-controlled folders will be somewhere else. This is what EGit prefers.
On my desktop, I have a workspaces directory for most of my Eclipse workspaces. Now that I use EGit, I also have an egit directory where I keep the local EGit repositories. The Eclipse workspaces that share using EGit reference a subdirectory of egit. It's from these local Git repositories that one pushes and pulls from GitHub.
Sorry for the length. I got a bit carried away.
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.