3

For one of my projects, when I try to create a git repository using these steps: select Team → Share Project → Git I would get this error:

enter image description here

Checking Eclipse error log view shows the following exception:

org.eclipse.jgit.errors.NoWorkTreeException: Bare Repository has neither a working tree, nor an index at org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1235) at org.eclipse.egit.ui.internal.sharing.ExistingOrNewPage.fillTreeItemWithGitDirectory(ExistingOrNewPage.java:518) at org.eclipse.egit.ui.internal.sharing.ExistingOrNewPage.createControl(ExistingOrNewPage.java:353) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174) at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736) at org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1182) at org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1241) at org.eclipse.jface.wizard.WizardDialog.access$4(WizardDialog.java:1238) at org.eclipse.jface.wizard.WizardDialog$8.run(WizardDialog.java:1227) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1225) at org.eclipse.team.internal.ui.wizards.ConfigureProjectWizardMainPage$2.doubleClick(ConfigureProjectWizardMainPage.java:156) at org.eclipse.jface.viewers.StructuredViewer$1.run(StructuredViewer.java:845) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49) at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175) at org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:843) at org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:1134) at org.eclipse.jface.viewers.StructuredViewer$4.widgetDefaultSelected(StructuredViewer.java:1246) at org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:249) at org.eclipse.jface.util.OpenStrategy.access$0(OpenStrategy.java:246) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:307) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) at org.eclipse.jface.window.Window.runEventLoop(Window.java:826) at org.eclipse.jface.window.Window.open(Window.java:802) at org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard.openWizard(ConfigureProjectWizard.java:224) at org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard.shareProjects(ConfigureProjectWizard.java:124) at org.eclipse.team.internal.ui.actions.ConfigureProjectAction$1.run(ConfigureProjectAction.java:39) at org.eclipse.team.internal.ui.actions.TeamAction$3.run(TeamAction.java:266) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70) at org.eclipse.team.internal.ui.actions.TeamAction.run(TeamAction.java:263) at org.eclipse.team.internal.ui.actions.ConfigureProjectAction.execute(ConfigureProjectAction.java:33) at org.eclipse.team.internal.ui.actions.TeamAction.run(TeamAction.java:515) at org.eclipse.team.internal.ui.actions.TeamAction.runWithEvent(TeamAction.java:549) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997) at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138) at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:610) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591) at org.eclipse.equinox.launcher.Main.run(Main.java:1450)

I can set up git repo for other projects without issue, how do I "reset" the state of this project so I can successfully set git repo? Thanks.

2
  • Just to be sure, did you try cleaning the project? Commented Jul 5, 2014 at 6:59
  • @Hassan yes, didn't help Commented Jul 5, 2014 at 8:26

3 Answers 3

1

The OP Kai comments

I think it's caused by some glitch in workspace setting:

  • merely removing the project from workspace,
  • moving it to another directory,
  • importing it back (with copy),

and voila the git repo is now magically found. –


If it was really a bare repo, then you would need to convert your bare repo into a non-bare one, in order to be able to check it out, and to import the checked out files in Eclipse.

cd /path/to/yourRepo.git
cd ..
mkdir yourRepo
mv yourRepo.git yourRepo
cd yourRepo
git config --local --bool core.bare false
git reset HEAD -- .

That error message should be displayed only if you had a (bare) repo in the path you mention when sharing your project.

Sign up to request clarification or add additional context in comments.

4 Comments

still having the same exception, and deleting .git dir and creating it doesn't help either
@Kai then try a different approach: make sure your .project and .git are in your project folder, at the same level as your src subfolder. And import that Eclipse project, and then share it like you do in your question.
hmm I think it's caused by some glitch in workspace setting, merely removing the project from workspace, moving it to another directory, importing it back (with the copy option), and voila the git repo is now magically found. Please update your answer with the comment and I'll accept your answer.
@Kai Ok, I have included your conclusion in the answer for more visibility.
1

Following is steps to create a project, use git manage it, and enable git in eclipse,
steps:
0. create a project in eclipse,
1. in command line, go to root folder of project, call: git init
2. in eclipse, right click project -> team -> share project, choose git, next,
3. check the option "use or create repository in parent folder of project" if not yet,
4. press "Finish", ok
5. right project -> team, now you can see git operations,

2 Comments

How do I "convert project to git project", can you be more specific in the steps required, thanks.
the issue I'm having is that when selection git an exception was thrown, thus the question (The same Eclipse configuration can work with other project, so it's this particular project that I am having a problem with)
0

Above answers didn't work form me. I had to open git perspective and add my local repository. Then delete projects in package explorer, and RMB import -> “projects from git”

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.