Importing cloned Git repository in Eclipse - eclipse

I am trying to create an Eclipse project from a cloned Git repository
I've cloned the repository from here:
https://github.com/nazgee/AndEnginePhysicsBox2DExtension
I have an existing project AndEnginePhysicsBox2DExtension and I want to create one called AndEnginePhysicsBox2DExtension-nazgee with the newly cloned repository.
When I try File -> Import -> Projects from Git and I select the new repository, I am unable to. I get this message:
Some or all projects cannot be imported because they already exist in the workspace.
I have the directories:
C:....AndEnginePhysicsBox2DExtension
C:....AndEnginePhysicsBox2DExtension-nazgee
Then I edit the .project file, changing:
AndEnginePhysicsBox2DExtension
to:
AndEnginePhysicsBox2DExtension-nazgeee
Also edited build.xml, adding -nazgee to project name
With this the error is now:
Invalid project description org.eclipse.egit.ui
Invalid project description org.eclipse.core.resources

I'd do it the other way around: rename your existing project in Eclipse and import the new one as you did.

Related

Eclipse EGit changes folder names after Pulls

I'm having trouble using EGit - specifically when pulling.
Basically, I cloned a Git repository in Eclipse using "Clone a git repository and add repository to this view" in Git Repositories view in Eclipse.
After that, I imported the Git project and used the "import using existing Eclipse project tab".
However, this changes the names of the packages. Instead of having a src folder that contains all the packages ("Model", "Controller", "Player" etc), it changes all the names to the packages to "src.Model", "src.Player" etc.
This is what the remote repository looks like
And this is what happens when I import the git project:
Because the package names had changed, it would compile. So initially I changed the package names back to their original (src.Player -> Player). However, when I pull, it changes all the package names to start with src.
Is there any way I can fix this?
Thank you
Your project folder instead of src is configured by mistake as a source folder:
In Project > Properties: Java Build Path, in the tab Source remove the project folder and add the src folder instead.
Commit and push the file .classpath which stores this project-specific setting

Folder structure in GitHub for my Eclipse Maven project

I am trying to push my eclipse maven project to my GitHub repository but the folder structure it is mapping is wrong.
My Maven Project is named DocOcr and i am trying to push it to DocOcr repository on GitHub using Egit in Eclipse. Although it is copying files but its creating one more folder under gitub DocOcr repo named DocOcr and copying all files under it.
Now my pom.xml and src are getting copied to GitHub as {myusername}/DocOcr/DocOcr
i want my pom.xml and src to get copied to {myusername}/DocOcr/.
Can someone please help ?
Double-check where your .git is located locally: it should be in the same folder as where your pom.xml is.
If it is not, backup that .git (in case you have done multiple commit), and see if you can initialize a new one where your pom.xml is, and import it: re-share your project as described in "How make Eclipse/EGit recognize existing repository information after update?".
Or, as described in "When I commit a project an extra project dir is created", create the Git repo with the option "Use or create repository in parent folder of project" enabled, at the very top of the "Configure Git Repository" dialog (Team -> Share Project... -> Git)
Which is exactly what I meant by "it should be in the same folder as where your pom.xml is."

EGit creates separate project folder in repository

I'm struggling to create a repository for my Maven project in Eclipse. Whatever I try it turns out like so:
\ProjectA
----\.git
----\ProjectA
--------\src
--------\pom.xml
While I'd like it to be like so:
\ProjectA
----\.git
----\src
----\pom.xml
Is there any way for it to not create a separate folder under the working tree?
I'm not sure if it is the only or the best way, but creating empty repo from git directly then moving files and reimporting in Eclipse did the trick.
In case anyone needs this later:
In folder you want your repo in:
git init
Copy your sources and pom.xml and other needed files there (I also recommend creating .gitignore file at this point), then:
git add --all
git commit --m "Initial commit msg"
Then open Eclipse, delete your project and reimport it as existing Maven project directly from your repo. In my case it already recognized repo as well.
From my understanding, you are trying to create a Git repository with a single Eclipse project, located at the root of the work directory.
open the EGit Repositories view and select the Create a new Repository action
enter the name of the directory in which the repository should be created and select Finish
make sure that auto-sharing projects is enabled (enabled by default, in doubt, see Preferences > Team > Git > Projects)
open the New Java Project and enter a project name
uncheck Use default workspace location and enter the exact same path as the repository work directory (see 2.)
go to the Package Explorer, select the new project, open the context menu and select Configure > Convert to Maven Project
The detour of creating a Java project first and then converting it into a Maven project seems necessary because the New Maven Project wizard apparently always adds the Group Id to the location path.

How to point github project at Eclipse

I have cloned a github repository and would now like to import the project into Eclipse.
The project name is 'myproject' and when cloned it is then created in my github repository :
c:\\users\\myrepo
Here are the files that were cloned :
The repository exists in a location which is different to the Eclipse workspace. How can I use this project within an Eclipse workspace ?
I'm going to answer this question as I found an answer while writing this.
Within Eclipse create a new project and set its type to the project type, in below example Scala :
Click next and on new dialog enter path to project location on local git directory :
Verify project setup is correct and click 'Finish'. The project should then be added to Eclipse and any changes made will be reflected in the git repository and so will be recognized by 'github for windows'
See http://wiki.eclipse.org/EGit/User_Guide#Starting_the_import_wizard and follow the path of Adding the clone you've already made.

Importing with EGit clones repository but doesn't let me import project

I just started my third repository on Github. I initialized the repository on the website with a README file and tried importing it into Eclipse with Egit. Like my other projects from Github, the import dialog worked fine and the repository was cloned. In my file explorer, I can see the folder Egit created, as well as the .git folder and the README from the repository.
However, when I get to the point where Eclipse wants me to choose a wizard for project import, everything stops working. I can't import an existing project, because none exists yet. If I try to import it as a general project, it doesn't let me go further because it claims:
/path/to/my/folder overlaps the location of another project: 'gnu_magic'
This is indeed the name of the project I'm trying to import, but as I just imported it for the first time that shouldn't be a problem.
If I use the new project wizard, it doesn't let me use the same folder name as the project, claiming that the folder is not empty (which is true, but strange when I'm using the wizard to create an entirely new project). If I give the folder another name, it creates a project but the project isn't connected to the repository - I have no way of committing my changes back to Github.
Deleting the gnu_magic folder and starting all over again brings the same results.
Is there a way to remove the metadata over that specific project from Eclipse's configuration? I don't want to lose my other projects but I would like to work with Egit on that project.
Another interesting fact: If I clone the repository manually and then try to import it into Eclipse, as a project from my file system, it doesn't let me becasue the source is in the heirarchy of the destination.
Or am I missing the point here completely? I'm just surprised that I was able to clone the other repositories without any problems. Working with them over the past few days has been quite easy.
The solution was a bit strange. Here's the steps to solve it:
Clone repository using EGit
Eclipse refuses to import project, claiming it already exists. Exit import dialog.
Create new project using existing code, using cloned repository
Share project with old repository
Now the project is once again connected to the repository. Be careful with this method because if something goes wrong you might commit over your old code. This solution works with Indigo and Juno.
I'm using Eclipse 4.2 Indigo, and I've been struggling with these same problems for a while now.
If you have already cloned a repository on your machine somewhere, using EGit or whatever, you can:
1) Create a new Eclipse project.
2) File -> Import -> General -> File System Choose the cloned repository location. This will import everything, including the .git folder within the repository, into your Eclipse project in your workspace. For this it doesn't matter whether there's .project files anywhere in the imported files or not.
3) Team -> Share Project -> Git The EGit plugin should detect the .git folder within your project and suggest settings accordingly. You will have a new local repository location addded to EGit's repositories which will point to the .git folder under your project's directory.