eclipse - Egit 将 Eclipse 项目文件夹添加到 git 存储库

标签 eclipse bitbucket egit

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

我将 repo 添加到“Git Repositories” View 并创建了一个同名的新项目。

我选择“团队 - > 共享项目”,然后提交并推送到上游。

现在我的存储库具有文件夹结构/my-long-project-name/My Long Project Name/

有什么办法可以让项目文件夹成为git仓库的根目录吗?

最佳答案

来自 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.



我知道这不是解决方案,但至少这为不得不忍受具有相同名称的附加文件夹提供了正当理由。

(不推荐!)解决方法

创建/修改远程存储库,然后克隆到一个新的本地项目 :

如果你还没有开始开发或者有能力将重复子文件夹的内容(在你的例子中,“我的长项目名称”)移动到 git 存储库的根目录,你 可以 通过相反的方式避免以两次相同的文件夹结束:
  • 将项目中的文件移动到远程存储库的根目录/如果这是一个新项目,则创建远程存储库。
  • “Git 存储库”在 Eclipse 中查看,找到 “克隆 Git 存储库并将克隆添加到此 View ” .按照以下步骤将存储库从 URI 克隆到本地文件夹。
  • 在同一 View 中,右键单击列表中的存储库并选择 “导入项目...”
  • 如果您有 .project根文件夹中的文件,即已经是 Eclipse 项目一部分的文件,选择 “导入现有项目”并选择根文件夹,然后观看 Eclipse 发挥它的魔力。
  • 如果这是一个新项目(或者源上的文件不是eclipse项目),选择“作为一般项目导入”,然后如果需要特定的项目类型,然后在Eclipse中修改项目类型。

  • 免责声明:我个人决定不使用这种解决方法并坚持使用 EGit 建议。

    关于eclipse - Egit 将 Eclipse 项目文件夹添加到 git 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15425640/

    相关文章:

    java - 获取 Intellij Idea 以突出显示不兼容的编译器代码?

    git - 创建分支后如何获取提交ID?

    Git 错误 : conq: repository does not exist

    java - 如何将存在冲突的大型 merge 分解为更易于管理的 block ?

    git - 我应该把 .gitignore 放在哪里以影响所有项目?

    java - Eclipse 调试断点仅在特定子类的虚拟调用时停止

    android - 刷新 Eclipse 中的可绘制对象列表?

    git - 如何比较 Bitbucket 服务器中的两个提交

    eclipse - 由于存储了错误的密码,因此无法使用 Eclipse (EGit) 从 Github 获取或拉取

    java - eclipse中的堆和栈