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
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 ? )
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二进制差异。
Use this
git apply example.patch
git add --patch
git commit
You can omit --patch flag, but you won't see every change and check patching process.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.