Why do I get a conflict with `git rebase -p`


I’m trying to understand how git rebase handles merges. I thought that with -p, it would be able to rebase conflicting merge that would have already been resolved. But it seams like it doesn’t.

Here is an example to illustrate the issue:

git init
touch a && git add . && git commit -m 'first commit'
git branch b
git branch c
echo 'a' >> a && git add . && git commit -m a

git checkout b
echo 'b' >> a && git add . && git commit -m b

git checkout master
git merge b
echo ab > a
git add .
git commit

git checkout c
touch c && git add . && git commit -m c

git checkout master
git rebase -p c

Here I get a conflict applying the merge commit.
Can someone explain to me why ?


No, -p just keeps the merge commits in the history instead of flattening them. The docs explicitly say that this doesn’t help with manual merging:

(from the man page)

Merge conflict resolutions or manual amendments to merge commits are not preserved.

Answered By – Paul Hicks

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published