216

After upgrading Eclipse from Helios to Indigo with EGit plugin 1.0.0, all my projects seem to have lost their metadata about their git repositories, respectively.

In Helios, every Eclipse project was a git repository on its own. When updating to Indigo, i hoped i could continue using the workspace from Helios. After the update, all projects are still present in the workspace; and in each project directory, there's still the .git subdirectory, but Eclipse seems to treat each project as if it wasn't a git repository already.

So, there's still all git metadata in the project folders, but eclipse doesn't recognize them. Is there another way to "reactivate" the git functionality?

tohuwawohu
  • 13,268
  • 4
  • 42
  • 61
  • 14
    Right click on a project and go to Team. Does it have the usual Git stuff, or does it allow you to "share" the project? If it says "share", then just set it up again. – Jeremy Aug 11 '11 at 13:58
  • 5
    @Jeremy: I tried this already - the usual git stuff is missing there, that's exactly the problem. Furthermore, using "share" doesn't allow me to use the repository that already exists in the project folder (using `gitk` on that folder works perfectly fine...). Using "share", i could clone that repo, but i don't want to clone it, i want to **use** it from within Eclipse. – tohuwawohu Aug 11 '11 at 14:08
  • 9
    Are you able to click on the checkbox that says "User or create Repository..." and select it? – Jeremy Aug 11 '11 at 14:33
  • 5
    @Jeremy: thanks a lot, now it works. I had to set the local repositories up again *before* using "Team -> Share... -> Use Repository". After adding them to the Git Repositores view, eclipse allowed me to "activate" them as you described. – tohuwawohu Aug 12 '11 at 08:41
  • I have identified some generic steps to reproduce this (not only after Eclipse upgrades) and opened a [bug report](https://bugs.eclipse.org/bugs/show_bug.cgi?id=543071). Feel free to upvote it to help it get prioritised. – Pyves Dec 28 '18 at 14:04

3 Answers3

339

Thanks to Jeremy, i found how to reactivate the repos myself. Basically, two steps were required:

  1. Add the (already existing) local repository to EGit's Git Repositories view;
  2. "Share" each of the projects again using "use or create repository".

The second step won't work if the repo isn't available in the repository view. So, after an eclipse upgrade, do the following:

Add the (already existing) local repository to EGit's Git Repositories view

  • Open the Git Repositories view: enter 'Git Repositories' View
  • Hit the "add" button (Tooltip: Add an existing local Git Repository to this view) add repositories
  • In the "Add Git Repositories" dialogue, under Search criteria, enter the workspace directory, select "Look for nested repositores", and hit Search: select repositories to add
  • Select the repositories you want to add and click OK

"Share" each of the projects again using "use or create repository"

  • Open you existing project in Eclipse's Project explorer;
  • Right-click and select "Team -> Share Project...": select share project
  • Select Git Project, and in the next dialogue, select "Use or create Repository in parent folder of project". Important: don't try to select the repository from the combo box that's visible when "Use or create Repository in parent folder of project" isn't selected - it won't work.

    select repository to use

The wizard suggests the local git repository that's located in the current project, so just hit Finish.

tohuwawohu
  • 13,268
  • 4
  • 42
  • 61
  • 98
    This is ridiculous. The fact that I had to Google to find this solution is sad. I'm surprised Eclipse doesn't just turn it on for projects with a `.git` directory. Thanks for asking this and finding a solution, as I've been banging my head against a wall for a while on this problem... – Nick Klauer Nov 22 '11 at 16:12
  • 4
    Wow, thanks a lot - this is he first place on the internet where I finally found out how to add git support to existing project (I must have recreated like 20 project so far from scratch)! – Tomáš Kafka Apr 23 '12 at 12:23
  • 5
    The last step in EGit is really misleading. The whole time I was thinking it is going to create new .git folder right above the project folder (this was because my project folder was two folders above...) Thanks for the answer! – Danail Nov 25 '12 at 08:44
  • Also possible as suggested here: http://www.eclipse.org/forums/index.php/t/236960/ just add the project to "Git Repositories" view first and then import the git project – Jeremy S. May 24 '13 at 12:53
  • That works only if your workspace contains git repo, but, if I understood things right, it is suggested that you use your local git repo outside your workspace. Eclipse shows the warning "Creation of repositories in the Eclipse workspace is not recommended". – Marko Bonaci Jul 31 '13 at 15:32
  • 2
    In case you have your git repo outside wks, go to `Show view > Git Repositories`; add local repository (as explained above). Then right-click on your project and select `Import Project > Import Existing Project`. – Marko Bonaci Jul 31 '13 at 15:56
  • I ran `git init` from Powershell so didn't have to do step 1; it was listed in the `Git Repositories' view. I just did step 2 and it got re -indexed. Thank you! – Prince Apr 12 '14 at 21:33
  • Just tried it with eclipse Luna. I only had to do step 1 "Add the (already existing) local repository to EGit's Git Repositories view;". After adding the repos, eclipse would link them then automatically to the projects in the workspace. – mxro Aug 08 '14 at 03:00
  • In case you can not access the Team/Share menu item and @Ivan's answer below also does not work you can follow the instructions [here](http://stackoverflow.com/questions/3767144/subclipse-not-showing-share-project-option-on-project-context-menu-in-eclipse) which reference SVN projects but worked on my Git project as well. – stav Aug 18 '14 at 12:44
  • This is frustrating, noone can think of this option. What does share means here. However, it worked for me, Thanks. – Ankit Zalani May 18 '16 at 08:46
  • I read through the answer and it still didn't make sense. The pictures that followed are really makes this such a valuable answer. After applying this, project explorer now suddenly shows which files have changed, which is what I was after. – demongolem Oct 19 '16 at 16:23
  • 2
    Still useful in 2019 with Eclipse 2019-06. My projects all somehow lost their git connection. This is despite the repositories being visible and pointing to the correct working directories. Been looking at how to fix this for ages. Thanks! – Stuart Brock Jul 31 '19 at 12:59
  • For me, add the already existing local repository was sufficient. With this step Eclipse recognize my project with git information. The "share" step was not necessary. Thanks. – gaelle3182 Sep 27 '19 at 10:46
  • And still in 2021, these steps required despite other aspects of GIT functioning fine (but not team) - Thanks! – Dave Nadler Apr 02 '21 at 14:30
50

Even after adding git repos I cannot do Team/Share on project, but what helped was to close and open project - you can also select multiple projects so action is quick

Ivan
  • 960
  • 7
  • 15
4

In my case, the git repos existed but the team context did not show the "Share this project" option. It looked like the project was partially configured with git.

I could fix the problem by deleting the project (without deleting the actual files) and then importing the project back to eclipse.

S Kodama
  • 101
  • 1
  • 4