Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit » Error when trying to use existing git repository
Error when trying to use existing git repository [message #919117] Fri, 21 September 2012 17:47 Go to next message
James Rice is currently offline James RiceFriend
Messages: 3
Registered: September 2012
Junior Member
I have an existing eclipse project that is a git repository, and am trying to use EGit with it. I started by selecting View->Other->Git->Git Repositories. This works fine, I can see the repo, and my branches, etc. Then, I attempt to select the Project, then Team->Share Project->Git, it sees a repository if I leave "Use or create repository in parent folder of project checked. When I click "Finish", I get the following error:

"Failed to initialize the Git team provider"

Has anyone run into this?

Are those instructions the way to use EGit in an existing project?
Re: Error when trying to use existing git repository [message #919566 is a reply to message #919117] Sat, 22 September 2012 05:01 Go to previous messageGo to next message
Eliseo Ocampos is currently offline Eliseo OcamposFriend
Messages: 15
Registered: September 2012
Junior Member
Hey James,

Do you have any stack trace of the error? What version of EGit/Eclipse are you using? Maybe you can follow the steps here [0] to import a repo in a proper way.

Regards,
Eliseo.

[0] http://help.eclipse.org/indigo/topic/org.eclipse.egit.doc/help/EGit/User_Guide/Tasks.html?path=19_0_2_1#Starting_from_existing_Git_Repositories
Re: Error when trying to use existing git repository [message #919937 is a reply to message #919117] Sat, 22 September 2012 14:25 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
In my experience the easiest and most reliable approach if the repository already contains one or more Eclipse project descriptions is as follows:

1. Add the existing repository to Git Repositories view (as you already did).
2. Right-click the newly added repository entry, select "Import Projects..." and follow the prompts.

That should do it.
Re: Error when trying to use existing git repository [message #920257 is a reply to message #919566] Sat, 22 September 2012 22:40 Go to previous messageGo to next message
James Rice is currently offline James RiceFriend
Messages: 3
Registered: September 2012
Junior Member
Thanks. I looked in the error log (didn't know there was one at the time I posted). It said that the "<my source dir> is not a valid location because the project contains a linked resource at that location". Which is true, because I have an "out of source" build as cmake recommends. My build looks like this.

topLevelDir/sourceDir/.git + source
topLevelDir/buildDir/.project + build stuff

So the I already have a project file, generated by cmake, and also already have a .git repository. I was just starting to use EGit and wanted to integrate with it.

If I use "Import existing projects", on my git repository, it complains because it can't find the .project file "No existing projects".

Must my .git directory be in the same place or above my .project file? This seems a little constraining, as keeping your build files out of source is fairly popular, and makes using .git easier, as I don't have to .gitignore everything.

[Updated on: Sat, 22 September 2012 22:41]

Report message to a moderator

Re: Error when trying to use existing git repository [message #920795 is a reply to message #920257] Sun, 23 September 2012 13:01 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
In the structure you describe, sourceDir is a Git repository with no Eclipse projects and buildDir is an Eclipse project not part of any Git repository. That's pretty odd. I also don't understand why you want the Eclipse .project file in the buildDir rather than at the top of the tree.

I would think you would want a structure like this:

topLevelDir/
  .git/
  .project
  .gitignore
  sourceDir/
  buildDir/


where .gitignore includes "buildDir/" (and whatever else you want to ignore)


Even better, consider adding an extra directory level for the current project to allow yourself the option of adding more projects to this repository later:


topLevelDir/
  .git/
  project1/
     .project
     .gitignore
     sourceDir/
     buildDir/


Re: Error when trying to use existing git repository [message #920984 is a reply to message #920795] Sun, 23 September 2012 17:48 Go to previous messageGo to next message
James Rice is currently offline James RiceFriend
Messages: 3
Registered: September 2012
Junior Member
You can do it like that, use of cmake encourages out-of-source builds. The build files don't clutter up the source tree, and you don't have to ignore it, since Git isn't even aware of it, or clean it up when you're done. Just another way of doing things. Also, we don't commit our .project files, they're generated, with our make files when we run cmake. The only thing we move into our CM repository is the source, cmake files and .gitignore(s). We have several collaborative projects, each cloned of a different repository. Each containing it's own .git directory. So, we wouldn't use the project level.

I guess I am coming from the opposite direction. Why does EGit care about the relative location of the repository and .project files? Since cmake is used quite a bit, integrates well with Eclipse, it would seem as though EGit should support this paradigm. But, there may be good reasons why not.
Re: Error when trying to use existing git repository [message #921109 is a reply to message #920984] Sun, 23 September 2012 21:00 Go to previous messageGo to next message
R Shapiro is currently offline R ShapiroFriend
Messages: 386
Registered: June 2011
Senior Member
As far as I know the EGit auto-importer is looking at the Git repository's working directory for .project files. Where else could it look? As I recall the SVN and CVS auto-importers behave the same way. So the reason the EGit importer says "no existing projects" is because there aren't any that it can see -- you've explicitly put the .project file somewhere else.

Conversely, you can manually import the .project in topLevelDir/buildDir, but since buildDir is not under version control, again by your explicit design, it won't be treated as an EGit project.

In short the behavior you report is exactly what I would expect.

Fwiw I've configured Eclipse C++ projects as I described earlier and it works fine, including EGit linkage, and with no "clutter". But I was not using cmake.

ps:

I don't know how you're using Eclipse here, but if you're treating the sources as just a tree of files, with no Eclipse builders, you can define a trivial .project in topLevelDir/sourceDir to do that and then commit it. This will give all developers EGIt access to your source tree.

[Updated on: Sun, 23 September 2012 21:11]

Report message to a moderator

Re: Error when trying to use existing git repository [message #922281 is a reply to message #921109] Mon, 24 September 2012 22:35 Go to previous message
Robin Rosenberg is currently offline Robin RosenbergFriend
Messages: 332
Registered: July 2009
Senior Member
R Shapiro skrev 2012-09-23 23.00:
> As far as I know the EGit auto-importer is looking at the Git repository's working directory for .project files. Where else could it look? As I recall the SVN and CVS
> auto-importers behave the same way. So the reason the EGit importer says "no existing projects" is because there aren't any that it can see -- you've explicitly put the
> .project file somewhere else.
>
> Conversely, you can manually import the .project in topLevelDir/buildDir, but since buildDir is not under version control, again by your explicit design, it won't be
> treated as an EGit project.
>
> In short the behavior you report is exactly what I would expect.
>
> Fwiw I've configured Eclipse C++ projects as I described earlier and it works fine, including EGit linkage, and with no "clutter". But I was not using cmake.

There are some thoughts about connecting containers (directories) at any level, but it's nowhere consistently done. This is kind of exotic, but I see the point
and it should be possible, though I'm not any team provider does it. Now we just someone willing to invest in this.

-- robin
Previous Topic:Pull with EGit
Next Topic:Is the stash/apply running well in EGit 2.0
Goto Forum:
  


Current Time: Tue Nov 25 23:20:28 GMT 2014

Powered by FUDForum. Page generated in 0.01767 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software