Returning Merged Trees to Git

I have something similar to the following story (but more complicated with multiple merges):

        F - G - H - K - L - …
       /           /
      /       I - J - M - …
     /       /
A - B - C - D - E - …

A′- B′- C′- D′- E′

A and A 'are the same trees with different stories.

I want to reset all dummy commits to equivalent commits on the primary branch, preserving merges (presumably manually specifying the hashes where the equivalent commits are on the restored tree). How to report K′that it should merge with H′and J′? Or do I need to recreate these merges manually?

If I do git rebase -p --onto B′ B L, it cannot be applied cleanly. I could reinstall Hon B′and Mon D′, and then recreate the merge Kmyself, then rebase Lon K′(and so on for other branches / joins not shown), but it will be honest work.

I looked through a few other questions , but none of them showed a merge.

+3
source share
2 answers

, , , git filter-branch. - --parent-filter, , , --all, . --commit-filter; , , . , --tag-name-filter cat .

, :

git filter-branch --parent-filter <somescript> --tag-name-filter cat -- --all

<somescript> / bash A A' B ( , script script git help filter-branch), script, .

- filter-branch , (refs/original/...), , - . , , , filter-branch , , , , ...

+3

? , git rebase -i A git A. , .

+1

All Articles