git 可以格式化补丁以便它可以与补丁程序一起使用吗?

发布于 2024-08-08 03:19:23 字数 63 浏览 5 评论 0原文

我需要从 git 存储库创建简单的补丁,可以使用简单的补丁命令行实用程序应用该补丁。

能做到吗?

I'd need to create simple patches from git repository that can be applied with plain simple patch command line utility.

Can it be done?

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

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

发布评论

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

评论(2

回忆躺在深渊里 2024-08-15 03:19:23

git diff 生成的补丁由 patch 工具正确处理。

patch 跳过 git 附加到补丁文件的所有附加信息。要应用补丁,您很可能需要 -p1 选项。

Patches, that git diff yields, are correctly processed by patch tool.

patch skips all the additional info git appends to the patch file. To apply the patch you most likely will need -p1 option.

日裸衫吸 2024-08-15 03:19:23

接受的答案如下:

补丁工具可以正确处理 git diff 生成的补丁。

我很确定我刚刚遇到了一个这是不正确的情况。 /usr/bin/patch 只是默默地(不报告错误)忽略了我的补丁,包括文件重命名信息,从而破坏了部署(幸运的是,我目前只是测试部署:-) ..我

发布这个替代答案是为了提醒其他遇到同样问题的人,因为我挠头了一段时间......而且对 StackOverflow 上答案的评论显然不能包含引号。

具有讽刺意味的是,我刚刚切换到统一 diff 格式来解决这个问题,现在我的部署以不同的方式中断,因为统一 diff 不能代表空文件的创建(例如 __init__.py )。谈论进退两难!

The accepted answer states the following:

Patches, that git diff yields, are correctly processed by patch tool.

I'm pretty sure I just ran into a case where this is incorrect. /usr/bin/patch just silently (without reporting an error) ignored my patch including file rename information, thereby breaking a deployment (fortunately I'm only testing the deployment at the moment :-) ...

I'm posting this alternative answer as a heads up for other people running into the same problem because I was scratching my head for a while... Also comments to answers on StackOverflow apparently can't contain quotes.

Ironically enough I just now switched to the unified diff format to overcome this problem and now my deployment breaks in a different way because unified diffs can't represent the creation of empty files (e.g. __init__.py). Talk about being between a rock and a hard place!

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