How to create patches for a merge?
- From
Geoffrey Lee <geoffreyj.lee@gmail.com>
- Date
- Feb 18, 2010, 11:40 UTC
- Message-ID
- <83d7aaa41002180340p2f9b7241h9c220b84ec5dd1d@mail.gmail.com>
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