Search code examples
gitrevision-historygit-cherry-pick

Merge old git commit with HEAD at master


I made some mistakes when merging commits of my colleagues. Now, we have discovered it and we need to apply old commit again, to choose manually the changes in the files. The situation looks like this:

A--\       /--F--\
    C--D--E       H--I
B--/^      \--G--/   ^
    |                |
WRONG MERGE       MASTER

I need git to ask me again to merge B with I, like B had never been in the history. In other words, I need git to ask me to choose the merge for all the files which differs in B and I commits. What's the best approach to do such thing? Can I achieve this with cherry pick? How?


Solution

  • Well, I have finally solved this way. I created diff from B (against master, I in my example) and manually applied all changes in meld difftool:

    [master]$ yes | git difftool <B hash> -t meld
    

    Then, added all the changed files and commited.