Git: how to change an old merge (in a series of merges)?

I have a situation that looks something like this:

(branch 1) A -- B -- C
                      \
(dev br)     E -- F -- G -- H
                 /         /
(branch 2) I -- J -- K -- L

All this worked fine. Unfortunately, I realized that I need to make changes to F (post commit between J and E), so I'm trying to do the following:

(branch 1) A -- B -- C
                      \
(dev br)     E -- F' -- G -- H
                 /         /
(branch 2) I -- J -- K -- L

My initial approach was to make another commit with corrections in dev brand perform a reinstall and pass it to F. However, this forces me to resolve all merge conflicts from CG merge and LH merge again, which were pretty involved, and I don't want them do.

, F, , G . , . git , ( , , -m). ?

rebase, git rebase --onto F' C G, (A-C, ) rebase.

, ? , .

+4
1

, , - git.

OK: Git .
, , .

" git , ".

.

F F':

  • :

    git cherry-pick --no-commit -m 1 vG
    git stash
    
  • ( ours)

    git merge -s ours -m "Gp" branch1
    git stash pop
    git commit --amend --no-edit
    

G' (G prime, Gp), branch1, .

, H, .

(OP Catsunami git stash, )

+2

Source: https://habr.com/ru/post/1652941/


All Articles