如何在没有安装 git 的情况下应用 git diff --binary 补丁?
我使用 git diff 生成可应用于远程服务器以更新项目的补丁。
在本地,我运行:
git diff --no-prefix HEAD~1 HEAD > example.patch
将 example.patch 上传到远程服务器并运行:
patch --dry-run -p0 < example.patch
如果 dry-run 成功,我运行:
patch -p0 < example.patch
这效果很好,除非 diff 包含二进制文件。今天发现可以使用:
git diff --no-prefix --binary HEAD~1 HEAD > example.patch
问题是生成的补丁文件无法使用patch应用。
在服务器没有安装 git 的情况下,如何应用这些二进制补丁文件?
我想保持使用空运行的能力。
谢谢
I use to git diff to generate patches that can be applied to remote server to update a project.
Locally, I run:
git diff --no-prefix HEAD~1 HEAD > example.patch
Upload example.patch to remote server and run:
patch --dry-run -p0 < example.patch
If dry-run is successful, I run:
patch -p0 < example.patch
This works well, except when diff includes binary files. Today, I found that I can use:
git diff --no-prefix --binary HEAD~1 HEAD > example.patch
The problem is that the generated patch file can not be applied using patch.
How can I apply these binary patch files without having git installed the server?
I would like to maintain ability to use dry-run.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
对于一个奇怪的答案,您可以使用 sshfs 将远程系统安装在您的任何位置确实有 git,然后以这种方式运行你的命令。从不同的参考框架解决问题:与其想知道如何在没有工具的地方运行命令,为什么不创建一个让数据到达您的工具的环境(通过 sshfs?)
For an outlandish answer, what you could do is use sshfs to mount the remote system upon where ever you do have git, and then run your commands that way. Approach the problem from a different frame of reference: Instead of wondering how to run commands where the tool is not, why not create an environment where the data comes to your tool ( via sshfs ? )
在许多情况下,在这种情况下,您无法使用更高级的工具创建数据并使用不太先进的工具来使用它。
patch
适用于非二进制 git-diff,这是一个令人高兴的巧合。git diff
引入了标准 diff 的扩展。为了实现这个目标,你可以:
scp
/rsync
new文件。对于小孩子来说还不错。In many situations and in this too, you can't create data with more advanced tool and use it with less advanced. It's a happy coincidence that
patch
works for non-binary git-diffs.git diff
introduces an extension to standard diff.To achieve the goal, you can:
scp
/rsync
new files. Not bad for small ones.根据变更日志,我们预计补丁版本> 2.6.1 支持 GIT 二进制差异。
According to the change log, we can expect patch versions > 2.6.1 to support GIT binary diffs.
使用这个
您可以省略 --patch 标志,但您不会看到每个更改并检查修补过程。
Use this
You can omit --patch flag, but you won't see every change and check patching process.