在没有 .project 文件的情况下将现有的 Git 项目导入 Eclipse

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7017653/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:31:26  来源:igfitidea点击:

Import an existing Git project into Eclipse without a .project file

eclipsegit

提问by Liam

I've forked and cloned a project to the local machine from GitHub using the terminal and am trying to import it into Eclipse.

我已经使用终端从 GitHub 分叉并克隆了一个项目到本地机器,并试图将它导入到 Eclipse 中。

The problem is the clone from GitHub doesn't have a .projectfile, so when I go import -> projects from Git, I can only import as a general project. How can I import the project to Eclipse without doing git init? Most of the solutions I saw have .projectalready there when they cloned it from Git.

问题是来自 GitHub 的克隆没有.project文件,所以当我从 Git 导入 -> 项目时,我只能作为一般项目导入。如何在不执行 git init 的情况下将项目导入 Eclipse?.project当他们从 Git 克隆它时,我看到的大多数解决方案已经存在。

回答by RoboAlex

Create a new java project, Untick "Use default location" and browse the git project path by clicking browse button. It works for me. I have just imported a Git, netbeans project into Eclipse through this simple method.

创建一个新的java项目,取消“使用默认位置”并通过单击浏览按钮浏览git项目路径。这个对我有用。我刚刚通过这个简单的方法将一个 Git、netbeans 项目导入到 Eclipse 中。

回答by estani

After a while I got it working as expected...

过了一会儿,我让它按预期工作......

Basically the wizard is broken. This is what worked for me (eclipse 4.2.2):

基本上巫师坏了。这对我有用(eclipse 4.2.2):

  1. You may use the wizard to import the git repository to your workspace.
  2. After that you need to close the wizard and open the git Repositories view. (Window->Show View->Others->Git->Git repositories)
  3. Right click on the repo you've just imported and select "Import Projects..."
  1. 您可以使用向导将 git 存储库导入您的工作区。
  2. 之后,您需要关闭向导并打开 git Repositories 视图。(窗口->显示视图->其他-> Git-> Git 存储库
  3. 右键单击您刚刚导入的存储库并选择“导入项目...”

I've imported a general project (it was SQL code only) and this time it worked as expected (The screen doesn't allow you to change the project name nor directory, which makes sense at this point.)

我已经导入了一个通用项目(它只是 SQL 代码),这次它按预期工作(屏幕不允许您更改项目名称或目录,这在这一点上是有意义的。)

Those are the same steps performed by the wizard, but apparently it doesn't get the information about the project being already deployed at the workspace, so you get the option to change those values and it complains about the project already existing there.

这些是向导执行的相同步骤,但显然它没有获得有关已在工作区部署的项目的信息,因此您可以选择更改这些值,并且它会抱怨该项目已存在于那里。

回答by Nayuki

You should create a new project in Eclipse and specify that the project be located in the existing directory.

您应该在 Eclipse 中创建一个新项目并指定该项目位于现有目录中。

Choose "Create project from existing source" in the wizard:

在向导中选择“从现有源创建项目”:

Eclipse: New Java Project

Eclipse:新的 Java 项目

回答by lory105

I use eclipse 3.7 ( indigo ) and I find this great solution:

我使用 eclipse 3.7 ( indigo ),我找到了这个很好的解决方案:

1) click on: Navigate-> Show In-> Project Explorer

1)点击:导航->显示在->项目资源管理器

2) from Filesystem folder, find and select the folder where the project is contained

2) 从 Filesystem 文件夹中,找到并选择项目所在的文件夹

3) right chick on folder, and select Promote to Project

3) 右键单击​​文件夹,然后选择“升级到项目”

回答by lory105

Do this:

做这个:

File> Import> General> Existing Projects Into Workspace

文件>导入>常规>现有项目到工作区

then:

然后:

  • select root directory: select the path in you pc where the project is
  • if you want to to copy the existing project in a new project into your workspace, check the field copy projects into workspace, otherwise don't check it and continue to work directly into the existing project
  • 选择根目录:在你的电脑中选择项目所在的路径
  • 如果要将新项目中的现有项目复制到您的工作区中,请选中该字段将项目复制到工作区中,否则不要选中它并直接继续工作到现有项目中