Eclipse创建git存储库故障

时间:2014-07-05 06:57:29

标签: eclipse git egit

对于我的一个项目,当我尝试使用以下步骤创建git存储库时:select Team → Share Project → Git我会收到此错误:

enter image description here

检查Eclipse错误日志视图会显示以下异常:

  

org.eclipse.jgit.errors.NoWorkTreeException:Bare Repository有   既不是工作树,也不是指数   org.eclipse.jgit.lib.Repository.getWorkTree(Repository.java:1235)at   org.eclipse.egit.ui.internal.sharing.ExistingOrNewPage.fillTreeItemWithGitDirectory(ExistingOrNewPage.java:518)     在   org.eclipse.egit.ui.internal.sharing.ExistingOrNewPage.createControl(ExistingOrNewPage.java:353)     在   org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:174)     在   org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:736)     在   org.eclipse.jface.wizard.WizardDialog.setWizard(WizardDialog.java:1182)     在   org.eclipse.jface.wizard.WizardDialog.updateForPage(WizardDialog.java:1241)     在   org.eclipse.jface.wizard.WizardDialog.access $ 4(WizardDialog.java:1238)     在   org.eclipse.jface.wizard.WizardDialog $ 8.run(WizardDialog.java:1227)     在   org.eclipse.swt.custom.BusyIndi​​cator.showWhile(BusyIndi​​cator.java:70)     在   org.eclipse.jface.wizard.WizardDialog.showPage(WizardDialog.java:1225)     在   org.eclipse.team.internal.ui.wizards.ConfigureProjectWizardMainPage $ 2.doubleClick(ConfigureProjectWizardMainPage.java:156)     在   org.eclipse.jface.viewers.StructuredViewer $ 1.run(StructuredViewer.java:845)     在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 at   org.eclipse.jface.viewers.StructuredViewer.fireDoubleClick(StructuredViewer.java:843)     在   org.eclipse.jface.viewers.StructuredViewer.handleDoubleSelect(StructuredViewer.java:1134)     在   org.eclipse.jface.viewers.StructuredViewer $ 4.widgetDefaultSelected(StructuredViewer.java:1246)     在   org.eclipse.jface.util.OpenStrategy.fireDefaultSelectionEvent(OpenStrategy.java:249)     在   org.eclipse.jface.util.OpenStrategy.access $ 0(OpenStrategy.java:246)     在   org.eclipse.jface.util.OpenStrategy $ 1.handleEvent(OpenStrategy.java:307)     在org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)     在org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)at   org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)     在org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)     在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)     在   org.eclipse.team.internal.ui.wizards.ConfigureProjectWizard.shareProjects(ConfigureProjectWizard.java:124)     在   org.eclipse.team.internal.ui.actions.ConfigureProjectAction $ 1.run(ConfigureProjectAction.java:39)     在   org.eclipse.team.internal.ui.actions.TeamAction $ 3.run(TeamAction.java:266)     在   org.eclipse.swt.custom.BusyIndi​​cator.showWhile(BusyIndi​​cator.java:70)     在   org.eclipse.team.internal.ui.actions.TeamAction.run(TeamAction.java:263)     在   org.eclipse.team.internal.ui.actions.ConfigureProjectAction.execute(ConfigureProjectAction.java:33)     在   org.eclipse.team.internal.ui.actions.TeamAction.run(TeamAction.java:515)     在   org.eclipse.team.internal.ui.actions.TeamAction.runWithEvent(TeamAction.java:549)     在   org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:241)     在   org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)     在   org.eclipse.jface.action.ActionContributionItem.access $ 2(ActionContributionItem.java:501)     在   org.eclipse.jface.action.ActionContributionItem $ 5.handleEvent(ActionContributionItem.java:411)     在org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)     在org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1057)at   org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4170)     在org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3759)     在   org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine $ 9.run(PartRenderingEngine.java:1113)     在   org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)     在   org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)     在   org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:138)     在org.eclipse.ui.internal.Workbench $ 5.run(Workbench.java:610)at   org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)     在   org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)     在   org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)     在   org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)     在   org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)     在   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)     在   org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)     在   org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)     在   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)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:606)at   org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)at at   org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)at at   org.eclipse.equinox.launcher.Main.run(Main.java:1450)

我可以毫无问题地为其他项目设置git repo,我如何"重置"这个项目的状态,所以我可以成功设置git repo?感谢。

3 个答案:

答案 0 :(得分:1)

以下是创建项目的步骤,使用git管理它,并在eclipse中启用git,
步骤:
0.在eclipse中创建一个项目,
1.在命令行中,转到项目的根文件夹,调用: git init
2.在eclipse中,右键单击项目 - >团队 - >分享项目,选择git,next,
3.如果还没有,请选中“在项目的父文件夹中使用或创建存储库”选项,
4.按“完成”,确定
5.正确的项目 - >团队,现在你可以看到git操作,

答案 1 :(得分:1)

OP Kai comments

  

我认为这是由工作区设置中的一些小故障引起的:

     
      
  • 仅从工作区中删除项目,
  •   
  • 将其移至另一个目录
  •   
  • 将其导回(带副本),
  •   
     

并且现在神奇地找到了git repo。 -


如果它真的是一个简单的回购,那么你需要convert your bare repo into a non-bare one,以便能够检查它,并在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 -- .

只有在路径you mention when sharing your project中有(裸)回购时,才会显示该错误消息。

答案 2 :(得分:0)

以上答案对我不起作用。 我不得不打开git透视图并添加我的本地存储库。 然后删除包浏览器中的项目,以及RMB导入 - > “来自git的项目”