Merge changes from one repo to another with different tree structures

后端 未结 3 885
无人共我
无人共我 2021-02-20 07:06

I have two Git repos, foo/master and bar/master:

In foo:

code_root
->dirA
  ->dirB
    -> *some files*

In bar:



        
3条回答
  •  礼貌的吻别
    2021-02-20 07:30

    So, you are saying the files are essentially the same in both in foo & bar, just that the ones in foo are newer than those in bar:

    If yes, then you can just take a diff:

    diff -b /path_to/foo/dirA/dirB/ /path_to/bar/ > diff.patch
    

    and then apply the patch onto bar:

    cd bar
    
    patch -p1 < diff.patch
    

    Update: As per OPs updated, he's looking to maintain commit history, above won't work in that case.

提交回复
热议问题