Egit将Eclipse项目文件夹添加到git仓库 [英] Egit adding Eclipse project folder to git repository

查看:310
本文介绍了Egit将Eclipse项目文件夹添加到git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在BitBucket上创建了一个新的git存储库,现在我想把它链接到Eclipse。



我把这个回购添加到了Git Repositories视图并创建了一个名称相同的新项目。



我选择Team - > Share Project,然后提交并向上推。



现在我的存储库有文件夹结构/ my-long-project-name /我的长项目名称/



有没有办法让项目文件夹git存储库的根?

解决方案

EGit Eclipse Wiki页面


这可能不是一个好想要使项目成为您的存储库的根文件夹



原因是您永远无法将另一个项目添加到此存储库中。项目文件将占据根文件夹;您仍然可以将项目添加为子文件夹,但是这种类型的项目嵌套已知会在整个场合引起许多问题。为了添加另一个项目,您必须将项目移动到存储库中的子文件夹,并将第二个项目添加为另一个子文件夹,然后才能执行此更改。




我知道这不是一个解决方案,但至少这给出了一个有效的理由,不得不忍受同名的附加文件夹。






(不推荐!)解决方法



创建/修改远程存储库,然后克隆进入新的本地项目



如果您尚未开始开发或者无法移动重复子文件夹的内容(在您的情况下) ,我的长项目名称)到git存储库的根目录,您可以可以避免使用相同文件夹的两倍,以相反的方式


  1. 将项目中的文件移动到远程存储库的根目录/创建远程存储库如果thi s是一个新项目。


  2. 在Eclipse中的Git Repositories视图中,找到克隆Git存储库并将克隆添加到此视图。按照步骤将您的存储库从您的URI克隆到本地文件夹。


  3. 在同一视图中,右键单击存储库在列表中选择导入项目...



    • 根文件夹中的 .project 文件,即已经是Eclipse项目的一部分的文件,选择导入现有项目并选择根如果这是一个新项目(或原始文件不是eclipse项目),请选择

    • strong>作为一般项目导入,然后如果需要特定的项目类型,则修改Eclipse中的项目类型。



免责声明:我个人决定不使用此解决方法,并坚持使用EGit推荐。


I've created a new empty git repository on BitBucket and now I want to link it to Eclipse.

I added the repo to the "Git Repositories" view and created a new project with the same name.

I select "Team -> Share Project" then commit and push upstream.

Now my repository has folder structure /my-long-project-name/My Long Project Name/

Is there any way to make the project folder the root of the git repository?

解决方案

From the EGit Eclipse Wiki page:

It is probably not a good idea to make a project the root folder of your Repository

The reason is that you will never be able to add another project to this Repository, as the .project file will occupy the root folder; you could still add projects as sub-folders, but this kind of project nesting is known to cause lots of problems all over the place. In order to add another project, you would have to move the project to a sub-folder in the Repository and add the second project as another sub-folder before you could commit this change.

I know this is not a solution, but at least this gives a valid reason for having to endure the additional folder with the same name.


The (not recommended !) workaround

Create/modify the remote repository, then clone into a new local project:

If you haven't started developing yet or can afford to move the contents of the duplicate sub-folder (in your case, "My Long Project Name") to the root of the git repository, you can avoid ending up with twice the same folder, by going the other way around:

  1. Move the files within the project to the root of the remote repository / Create the remote repository if this is a new project.

  2. In the "Git Repositories" view in Eclipse, find the "Clone a Git repository and add the clone to this view". Follow the steps to clone your repository from your URI to a local folder.

  3. In the same view, right-click the repository in the list and choose "Import Projects..."

    • If you have a .project file in the root folder, i.e. the files where already part of an Eclipse project, choose "Import existing projects" and choose the root folder, then watch Eclipse do its magic.

    • If this is a new project (or the files on the origin are not an eclipse project), choose "Import as general project", then modify the project type in Eclipse afterwards if you need a specific project type.

Disclaimer: I personally decided not to use this workaround and to stick with the EGit recommandations.

这篇关于Egit将Eclipse项目文件夹添加到git仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆