问题描述
当我尝试使用 git am
来修补它时,它会显示修补程序格式检测失败,以perforce diff。
Taking perforce diff when I try to patch this using git am
, it says "Patch format detection failed".
如何从perforce获取我的更改并将其应用到git分支?
How do I get my changes from perforce and apply it to git branch?
这是差异的前几行
This is the first few lines of diff
==== //depot/a.c#162 - /asdf/a.c ====
4326a4327,4642
> /*
> *----------------------------------------------------------------------------
> *
> * --
推荐答案
a href =http://www.perforce.com/perforce/doc.current/manuals/cmdref/diff.html> p4 diff -du
获取,这对于像,这是(我相信)Git理解的唯一格式。
Make sure you produce the diff with p4 diff -du
to get the unified diff format, which works much better with tools like patch
, and is (I believe) the only format that Git understands.
您还可能需要编辑修补程序以取出Perforce语法;您可以看到,文件名称显示为 // depot / ac#162
,其中 patch
和 git apply
可能会被解释为实际的文件名; 交流转换器#162
。尝试删除#162
部分(如果它出现在您的修补程序中)。
You also may need to edit the patch to take out the Perforce syntax; as you can see, the file name appears as //depot/a.c#162
, which patch
and git apply
may be interpreting as the actual filename; a.c#162
. Try removing the #162
part if that appears in your patch.
并且取决于您在何处应用修补程序,您可能需要将 -p1
传递给补丁
或 git apply
为了剥离领先的 /
或 -p2
以剥离整个主目录。
And depending exactly where you are applying the patch, you may need to pass -p1
to patch
or git apply
in order to strip off the leading /
, or -p2
to strip off the entire leading directory.
这篇关于perforce diff到git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!