0

Here is my case:

├── (c0) ── (c1) ── (c2-merge-commit) ── (b0)── (b1-merge-commit)

I wanted to combine c0, c1 and c2 into one commit and have this:

├── (squashed : c0, c1, c2-merge-commit) ── (b0)── (b1-merge-commit)

So i carried my HEAD to c2, then back to c0 and squash merge to c2 (HEAD@{1})

git merge --squash HEAD@{1}

This part went quite well and i had :

├── (squashed : c0, c1, c2)

Now i need to add 2 commits (b0) and (b1-merge-commit). I used cherry-pick, but in that case i need to resolve conflict for b0. But i dont want to resolve conflict again as i actually did it with (b1-merge-commit).

As a solution; I first squashed b0 and b1 into new commit; and then cherry-pick this one over (squashed : c0, c1, c2). But obviously this solution won't scale if i would do squashing +10 commits past with so many merge commits flying around.

TLDR : I wanna carry two commits on top of my branch; one of them is actual change(b0) with conflicts and other one is merge commit where conflicts are actually resolved. When i cherry-pick one by one, git asks me to handle conflicts of b0 where conflict actually resolved with merge commit on b1. I could only manage to do it with squashing b0 and b1 into one new commit, and cherry-pick it on my branch.

Kerem atam
  • 2,387
  • 22
  • 34

1 Answers1

0

I could find two approaches so far, but non of them gives what exactly i want. But atleast i wouldnt need to resolve conflicts again.

First one, as it is mentioned in question already. I did squashing for b0 and b1 in another branch. Turn back to original branch and then cherry-pick squashed b0 and b1:

├── (squashed : c0, c1, c2)-(squashed: b0, b1)

Second one, cherry-pick merge commit directly: This one is more faster and simpler.

$> git cherry-pick -m 1 <hash-b1>

And branch now look like this :

├── (squashed : c0, c1, c2)-(b1-merge-commit)
Kerem atam
  • 2,387
  • 22
  • 34