我想将补丁应用于当前目录中的文件.补丁文件中的路径只显示/ FILETOPATCH.something b/FILETOPATCH.something.如果我使用它与git apply它不起作用.要修补的文件和.patch文件位于同一目录中.
我在许多变种中尝试了--directory和-p选项但没有成功.
使用补丁-p1 <patchfile.patch工作正常.
如果我从.patch文件中的存储库根目录设置一个绝对路径,那么它也可以使用git apply,但是必须有一种方法可以不编辑补丁fieles.
这将适用于git apply
diff --git a/htdocs/something/whatever/file.code b/htdocs/something/whatever/file.code
index 385f3f4..07d8062 100644
--- a/htdocs/something/whatever/file.code
+++ b/htdocs/something/whatever/file.code
...
PATCH DATA
...
Run Code Online (Sandbox Code Playgroud)
但不是这个(这是原作)
diff --git a/file.code b/file.code
index 385f3f4..07d8062 100644
--- a/file.code
+++ b/file.code
...
PATCH DATA
...
Run Code Online (Sandbox Code Playgroud)
任何想法如何让git应用工作而不更改补丁文件?
如何制作 diff 文件?
好吧,这就是我如何应用补丁的过程。希望对您有帮助
git diff --full-index <SHAsum of commit A> <SHAsum of commit B> > change.patch (full index for binary file)
git apply --check --verbose --summary change.patch (check if it is in good patch or not)
git apply --verbose change.patch
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3834 次 |
| 最近记录: |