2014-07-05 148 views
3

對於我的項目之一,當我嘗試使用下列步驟來創建一個Git倉庫:select Team → Share Project → Git我會得到這個錯誤:Eclipse中創建的Git倉庫故障

enter image description here

檢查Eclipse的錯誤日誌視圖顯示以下例外:

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)

我可以設置爲沒有問題,其他項目混帳回購協議,我該如何「重啓」這個項目的狀態,所以我可以成功設置混帳回購協議?謝謝。

+0

可以肯定的是,您是否嘗試清理該項目? – Hassan

+0

@Hassan是的,沒有幫助 – Kai

回答

1

OP Kaicomments

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. –


如果它是一個真正的裸回購,那麼你就需要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一(裸)回購顯示。

+0

仍然具有相同的例外,並刪除.git目錄和創建它並沒有幫助 – Kai

+0

然後@Kai嘗試一種不同的方法:確保你的'.project'和'.git'在你的項目文件夾,在與您的'src'子文件夾相同的級別。然後導入該Eclipse項目,然後像在問題中那樣分享它。 – VonC

+0

嗯我認爲這是由工作區設置中的一些小故障引起的,只是從工作區中移除項目,將其移動到另一個目錄,將其導回到另一個目錄(使用複製選項),並且現在魔法地找到了git repo。請用評論更新您的答案,我會接受您的回答。 – Kai

1

下面是步驟來創建一個項目,使用git管理它,並能夠在Eclipse中的git,
步驟:
0.在Eclipse中創建一個項目,
1.在命令行,去的根文件夾項目中,調用:git的初始化在eclipse
2,右鍵單擊項目 - >團隊 - >共享項目,選擇混帳,接下來,
3.勾選「使用或項目的父文件夾中創建庫」如果還沒有,
4.按「完成」,確定
5. r飛行項目 - >團隊,現在你可以看到git的操作,

+0

我如何「將項目轉換爲git項目」,您可以在所需的步驟中更具體,謝謝。 – Kai

+0

@kai請參閱更新的答案, –

+0

我遇到的問題是當選擇git引發異常時,因此問題(相同的Eclipse配置可以與其他項目一起工作,所以這是我遇到問題的特定項目與) – Kai

0

以上答案並不適用於我。 我不得不打開git透視圖並添加我的本地存儲庫。 然後刪除包瀏覽器中的項目以及RMB import - >「git項目」