Merge changes from one repo to another with different tree structures

后端 未结 3 887
无人共我
无人共我 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

    Check out the git book and git magic. Depending on the exact changes, perhaps a round of history rewriting (git filter-branch and friends; or brute-force application of git rebase --interactive, straightening out each commit) can restore sanity to the mangled clone, and then allow a clean merge.

    Other alternative is to export each commit as a patch (essentially run git format-patch), recover the commit data from there and reverse engineer the patches to apply. You could even use the oportunity to rewrite a cleaner/simpler history when doing this.

    Clearly the viability depends on the extent of the divergence, and how many "wrongly applied" commits are at stake.

提交回复
热议问题