【问题标题】:Eclipse: Relocating a git repo from project to workspaceEclipse:将 git 存储库从项目重定位到工作区
【发布时间】:2010-09-18 23:47:52
【问题描述】:

我从事 Eclipse 插件项目已经有一段时间了,我遇到了需要拆分项目以将测试用例与插件包分开的情况。我使用 git 作为版本控制。

为了简单地描述这一点,我正在像这样对旧项目进行版本控制:

workspace/
  |
  +-- myplugin/
         |
         +-- .git/ <-- Here be the git repository
         |
         +-- /* Source code, project stuff, etc. */

...我需要在一个单独的项目中进行插件测试(这样就不需要 jUnit 作为插件的必需捆绑包)。而且我希望存储库对工作区中的所有内容进行版本控制。像这样:

workspace/
  |
  +-- .git/ <-- The repository should be relocated here instead…
  |
  +-- myplugin/
  |      |
  |      +-- /* Source code, project stuff, etc. */
  |
  +-- myplugin-test/
         |
         +-- /* Unit tests and stuff… */

有没有一种简单的方法可以在不丢失旧项目历史的情况下做到这一点?

【问题讨论】:

    标签: eclipse git version-control refactoring relocation


    【解决方案1】:

    这是伪代码的工作流程:

    cd 工作区/myplugin mkdir myplugin git mv * myplugin # 你可能需要手动对所有文件/文件夹执行此操作 mkdir myplugin-test # 将文件移动/添加到 myplugin-test git commit -a -m "重组" cd 工作区 mv myplugin myplugin_old mv myplugin_old/* 。 # 你应该得到请求的结构

    【讨论】:

    • git mv * myplugin 不起作用 - 它说“致命:无法将目录移动到自身,source=myplugin,destination=myplugin/myplugin”。改用 git mv $(git ls-files) myplugin/。
    • 这看起来不错,但在最后一步中确保您还获得了所有以“.”开头的文件,例如“.git”和“.gitignore”(* 不会选择它们) .
    猜你喜欢
    • 1970-01-01
    • 2015-07-31
    • 2012-10-22
    • 2013-10-31
    • 2010-09-20
    • 1970-01-01
    • 2017-05-25
    • 2014-07-25
    • 2023-04-06
    相关资源
    最近更新 更多