强制 diff 到 git

发布于 2024-12-18 02:07:07 字数 313 浏览 1 评论 0 原文

当我尝试使用 git am 修补它时,进行 perforce diff 时,它显示“修补程序格式检测失败”。

如何从 perforce 获取更改并将其应用到 git 分支?

这是 diff 的前几行

==== //depot/a.c#162 - /asdf/a.c ====
4326a4327,4642
> /*
>  *----------------------------------------------------------------------------
>  *
>  *  --

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

波浪屿的海角声 2024-12-25 02:07:07

确保使用 p4 diff -du 获取统一 diff 格式,与 patch,并且是(我相信)Git 理解的唯一格式。

您可能还需要编辑补丁以删除 Perforce 语法;如您所见,文件名显示为 //depot/ac#162,其中 patchgit apply 可能会解释为实际的文件名文件名; ac#162。如果您的补丁中出现了 #162 部分,请尝试删除它。

并且根据您应用补丁的具体位置,您可能需要将 -p1 传递给 patchgit apply 以去除前导/-p2 删除整个主目录。

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.

棒棒糖 2024-12-25 02:07:07

使用git apply,或者失败使用patch(1),然后提交结果。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文