perforce diff to git

别来无恙 提交于 2019-12-02 03:09:47

问题


Taking perforce diff when I try to patch this using git am, it says "Patch format detection failed".

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
> /*
>  *----------------------------------------------------------------------------
>  *
>  *  --

回答1:


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.

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.

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.




回答2:


Use git apply, or failing that use patch(1) directly, then commit the results.



来源:https://stackoverflow.com/questions/8289306/perforce-diff-to-git

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!