git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Next: Junio C Hamano
Message 1 of 5 in “How to create patches for a merge?”
  1. Geoffrey LeeFeb 18, 2010
  2. Junio C HamanoFeb 18, 2010
  3. Jeff KingFeb 18, 2010
  4. Geoffrey LeeFeb 19, 2010
  5. Clemens BuchacherFeb 20, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.