Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

How to create patches for a merge?

From: Geoffrey Lee <hidden>
Date: 2016-06-15 22:48:18

When I use "git format-patch", it doesn't seem to include merges. How
can I perform a merge and then e-mail it to someone as a set of
patches?

For example, let's say that I merge two branches and perform another
commit on top of the merge:

git init

echo "initial file" > test.txt
git add test.txt
git commit -m "Commit A"

git checkout -b foo master
echo "foo" > test.txt
git commit -a -m "Commit B"

git checkout -b bar master
echo "bar" > test.txt
git commit -a -m "Commit C"

git merge foo
echo "foobar" > test.txt
git commit -a -m "Commit M"

echo "2nd line" >> test.txt
git commit -a -m "Commit D"

This creates the following tree:

    B
  /   \
A       M - D
  \   /
    C

Now I try to checkout the initial commit and replay the above changes:

git checkout -b replay master
git format-patch --stdout master..bar | git am -3

This produces a merge conflict. In this scenario, "git format-patch
master..bar" only produces 3 patches, omitting "Commit M". How do I
deal with this?

-Geoffrey Lee
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help