eclipse 从源代码管理打开现有项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4054216/
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
Opening existing project from source control
提问by Andrew
I've been pushing my source to a Mercurial repository. Today I needed to delete my local copy and re-clone. I did this by simply moving my local copy somewhere else (just in case) and typing "hg clone url".
我一直在将我的源代码推送到 Mercurial 存储库。今天我需要删除我的本地副本并重新克隆。我通过简单地将我的本地副本移到其他地方(以防万一)并输入“hg clone url”来做到这一点。
This part has worked just fine.
这部分工作得很好。
However, when I try to pull the newly cloned local copy into Eclipse, I get the following error:
但是,当我尝试将新克隆的本地副本拉入 Eclipse 时,出现以下错误:
/Users/Andrew/Dev/Workspace/Android/MyProject overlaps the location of another project: 'MyProject'
My guess is that I have been committing some meta file or something that I shouldn't have. Does anyone have any ideas? Here is my .hgignore:
我的猜测是我一直在提交一些元文件或我不应该拥有的东西。有没有人有任何想法?这是我的.hgignore:
syntax: regexp
\.DS_Store
.swo
.swp
.metadata/
/bin/
Note: Looks like my hgignore is not blocking the gen folder. Could this be part of the problem?
注意:看起来我的 hgignore 没有阻止 gen 文件夹。这可能是问题的一部分吗?
回答by Joseph
There is a bug in Eclipse what won't let you create an Android project from existing sources:
Eclipse 中有一个错误,它不允许您从现有源创建 Android 项目:
http://code.google.com/p/android/issues/detail?id=8431
http://code.google.com/p/android/issues/detail?id=8431
You have to move MyProjectto a folder that doesn't have any other projects in its sub-directories. You can then make a new project from existing source with MyProject. Remove the new project from the workspace without deleting the contents on disk and move it back to your Androidfolder. Now do an Import -> General -> Existing Project into Workspace, and MyProjectshould be available to import.
您必须将MyProject移动到其子目录中没有任何其他项目的文件夹。然后,您可以使用MyProject从现有源创建一个新项目。从工作区中删除新项目而不删除磁盘上的内容并将其移回您的Android文件夹。现在执行Import -> General -> Existing Project into Workspace,并且MyProject应该可以导入了。
This is the only way I've been able to do it.
这是我能够做到的唯一方法。
回答by M. P.
Ok, I'll try to sum it up, after I faced similar problems and wasted some time:
好吧,在我遇到类似的问题并浪费了一些时间之后,我会尝试总结一下:
Eclipse Juno /4.2 SR1 (however I think it is a general misunderstanding of how eclipse imports projects)
Eclipse Juno /4.2 SR1(不过我认为这是对 Eclipse 如何导入项目的普遍误解)
- If you want your new project "connected" to git/mercurial, you'll have to clone and import via "Import/Git/Import from Git"
- It will fail if your "workspace dir" equals the "local destination dir". A git clone via egit MUST NOT be placed! in the "eclipse workspace dir"!
- 如果你想让你的新项目“连接”到 git/mercurial,你必须通过“Import/Git/Import from Git”克隆和导入
- 如果您的“工作区目录”等于“本地目标目录”,它将失败。 不得放置通过 egit 的 git 克隆!在“eclipse工作区目录”中!
The project import will fail because the projectname in the cloned ".project file" already exists in the eclipse workspace dir when the import occurs.
项目导入将失败,因为在导入时克隆的“.project 文件”中的项目名称已存在于 eclipse 工作区目录中。
回答by Jacob
My sollution was just to import as general
project not an android
one.
我的解决方案只是作为general
项目而不是一个项目导入android
。
回答by javahead76
I ran into this problem when trying to import a git repo project and it's submodules. I ended up using import -> git -> Projects from Git (git plugin). This understood the concept of a project within a project just fine. The project is now monitored by that plugin. It's a good enough tradeoff for me.
我在尝试导入 git repo 项目及其子模块时遇到了这个问题。我最终使用了 import -> git -> Projects from Git(git 插件)。这样理解项目中项目的概念就好了。该项目现在由该插件监控。这对我来说是一个足够好的权衡。
回答by Matthieu
I think the problem is that you moved your local copy away and then you try to add another project into Eclipse at the same location as what you had before and you are just confusing Eclipse...
我认为问题在于您将本地副本移走了,然后您尝试将另一个项目添加到与之前相同的位置的 Eclipse 中,而您只是混淆了 Eclipse ...
I would recommend to try to use command line commands for Mercurial and when you get into Eclipse, first clean up existing projects before adding another one.
我建议尝试对 Mercurial 使用命令行命令,当您进入 Eclipse 时,首先清理现有项目,然后再添加另一个项目。