Eclipse create git repository failure

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

  • How do I add existing eclipse java project to git
  • How to use eclipse project from github for Android development
  • Why does my Eclipse “count objects” before pushing upstream to GIT each time
  • How to use EGit with SSH on Windows?
  • Subclipse and Tortoise SVN together
  • Should I commit files that are changed by eclipse
  • 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.

  • Dropbox and git, could it cause conflicts?
  • How to use old SSH key from Windows to Ubuntu?
  • Keeping remote repository in sync through a rebase
  • Can I use command-line Git tools and TortoiseGit simultaneously?
  • How do i checkout an android project from an SVN repository
  • Git alias to delete remote branch
  • 3 Solutions collect form web for “Eclipse create git repository failure”

    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.

    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,

    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”

    Git Baby is a git and github fan, let's start git clone.