Let's assume that there are two branches, master
and slave
, and they edit the same file and the same line. Initially, the contents of the file is
foo bar
then in the branch slave
it is edited to become
foo bar baz
Now the user of branch slave
formats the patch (git format-patch master
) and sends it to the user of the branch master
. In the same time, in the branch master
the same file is edited and becomes
foo bar spam eggs
The patch cannot be applied, and master
asks slave
to merge and make a new patch. When master
is merged into slave
and the conflict is resolved, it's time to reformat the patch. The commit graph looks like this:
slave: master:
foo bar baz spam eggs
| \
| \
| foo bar spam eggs
| |
foo bar baz |
\ |
\ |
+--------- foo bar
The latest commit (merge) on slave
looks like:
@@@ -1,1 -1,1 +1,1 @@@
- foo bar baz
-foo bar spam eggs
++foo bar baz spam eggs
However, if we now run git format-patch master
, we still get exactly the same patch as before, which doesn't take merge and conflict resolution into account:
@@ -1 +1 @@
-foo bar
+foo bar baz
How do you format a patch which would apply against the latest master? I'd like to do it without rebase
.
Update: git format rev1..rev2
, where rev1
and rev2
are heads of the master
and custom
branches respectively, doesn't include changes related to conflict resolution. git-diff
formats a valid patch, but omits commit messages.
Why are you using patches? You should be pushing and pulling between repos.
A merge is not something you can make a patch from. It will follow the first parent only. You can get what you want by using git diff
and formatting for patch while specifying the 2 different commits to differentiate between.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With