I created a patch from three commits using
git format-patch <revision_three_commits_ago>
This creates three patch files that I mailed from my notebook and read the mail on my desktop computer (both are Windows boxes).
When I do now
git am --3way --ignore-space-change *.patch
the patches apply, but I don't get the same SHA1 IDs for the commits. Searching a bit in the patched files, I found that the modified lines on my desktop computer end with LF
, whereas the modified lines on the notebook (where I created the patch) end with CR LF
.
So, my first thought was to call git am
without --ignore-space-change
, but this gives me an error (patch does not apply).
How could I tell git format-patch
or git am
about how to handle the line endings (msysgit 1.7.4)?
Do I really have to take VIM and change the file format from UNIX
to DOS
before I can apply the patches?
EDIT: Not even modifying the patch files with VIM helps: I thought, set ff=dos
and a :%s/^M//g
would help, but it doesn't!
In my opinion, applying a patch should result in exactly the same content and also the same commit hash like I pulled from the other repo where the patch was created. Am I thinking wrong about that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…