[英]how to merge git .diff file to source code?
I export one diff file, use ' git diff HEAD^ HEAD > a.diff
' . 我导出一个diff文件,使用'
git diff HEAD^ HEAD > a.diff
'。 So, I wanna use a.diff file patch to another source code. 所以,我想使用a.diff文件补丁到另一个源代码。 I use command '
patch -p0 < a.diff
', but it not works. 我使用命令'
patch -p0 < a.diff
',但它不起作用。 said, "can't find files." 说,“找不到档案。” So, my question is: how to path a.diff file to source code?
所以,我的问题是:如何将a.diff文件路径化为源代码? Can someone help me solving this quesiont?
有人可以帮我解决这个问题吗? thanks a lot.
非常感谢。
With git
the diff output requires removing up to the first /
in the path. 使用
git
,diff输出需要删除到路径中的第一个/
。 This should work: 这应该工作:
patch -p1 < a.diff
Also try using git format-patch
and git am
(preserves logs if applying patch in another git directory): 另外尝试使用
git format-patch
和git am
(如果在另一个git目录中应用补丁,则保留日志):
rm -rf *.patch
git format-patch -1
git am *.patch
rm -rf *.patch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.