如何合并两个连续的git存储库 [英] How to merge two sequential git repositories

查看:109
本文介绍了如何合并两个连续的git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当独特的情况:


  • 我有一个名为Project1的仓库,我花了几美元b $ b月。
  • 一年后,我创建了存储库Project1_Again,
    在Project1离开的地方启动了。

  • 现在,我想修改历史是连续的,所以我希望它们合并在一起,就好像这个新的存储库从未被创建过一样。



这可能吗?



澄清:

回购:Project1




  • rev1:main.cpp包含内容h

  • rev2:main.cpp包含内容hello
  • rev3:main.cpp包含内容hello world

    $ b

    回购:Project1_Again




    • rev1:main.cpp包含内容hello world

    • rev2:main.cpp包含hello world again内容


    我的目标是将Project1的修订历史记录到Project1_Again中:

    回购:Project1_Again




    • rev1:main.cpp包含内容h

    • rev2:main.cpp包含内容hello

    • rev3:main.cpp包含内容hello world

    • rev4:main.cpp包含内容hello world again project1 按时间顺序排列在

      解决方案 > project2 :

        cd project1 
      git checkout --orphan merging_project2
      git rm -rf。
      git pull protocol:// project2_address / master
      git merge -Xours master


      I have a rather unique situation:

      • I have a repository called Project1 that I worked on for a few months.
      • A year later, I created the repository Project1_Again that took off where Project1 left off.
      • Now, I would like the revision history to be continuous, so I would like them merged together, as if that new repository had never been created.

      Is this possible?

      To clarify:

      Repo: Project1

      • rev1: main.cpp has contents "h"
      • rev2: main.cpp has contents "hello"
      • rev3: main.cpp has contents "hello world"

      Repo: Project1_Again

      • rev1: main.cpp has contents "hello world"
      • rev2: main.cpp has contents "hello world again"

      My goal is to get Project1's revision history into Project1_Again:

      Repo: Project1_Again

      • rev1: main.cpp has contents "h"
      • rev2: main.cpp has contents "hello"
      • rev3: main.cpp has contents "hello world"
      • rev4: main.cpp has contents "hello world again"

      解决方案

      For project1 chronologically before project2:

      cd project1
      git checkout --orphan merging_project2
      git rm -rf .
      git pull protocol://project2_address/ master
      git merge -Xours master
      

      这篇关于如何合并两个连续的git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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