我有3个文件a\test.txt , b\test.txt和c\test.txt :
a\test.txt :
x y zb\test.txt :
x z p qc\test.txt :
x y现在我在a和b之间创建了一个补丁:
git diff --no-prefix --binary a b > mypatch.patch导致这个补丁:
diff --git a/test.txt b/test.txt index 1b2c8f8..e0b3aec 100644 --- a/test.txt +++ b/test.txt @@ -1,3 +1,4 @@ x -y -z \ No newline at end of file +z +p +q \ No newline at end of file接下来,我想在c\test.txt上应用mypatch.patch:
cd c:\ git apply --ignore-space-change --ignore-whitespace ../mypatch.patch我收到错误:
../mypatch.patch:10: trailing whitespace. z ../mypatch.patch:11: trailing whitespace. p error: patch failed: test.txt:1 error: test.txt: patch does not apply我在这里阅读了一些帖子,但仍然没有设法让它应用任何想法?
我在mypatch.patch中看不到任何尾随空格
I have 3 files a\test.txt, b\test.txt and c\test.txt:
a\test.txt :
x y zb\test.txt :
x z p qc\test.txt :
x yNow I created a patch between a and b:
git diff --no-prefix --binary a b > mypatch.patchResulting in this patch:
diff --git a/test.txt b/test.txt index 1b2c8f8..e0b3aec 100644 --- a/test.txt +++ b/test.txt @@ -1,3 +1,4 @@ x -y -z \ No newline at end of file +z +p +q \ No newline at end of fileNext I want to apply mypatch.patch on c\test.txt:
cd c:\ git apply --ignore-space-change --ignore-whitespace ../mypatch.patchI get the error:
../mypatch.patch:10: trailing whitespace. z ../mypatch.patch:11: trailing whitespace. p error: patch failed: test.txt:1 error: test.txt: patch does not applyI have read a bunch of post here on SO but have still not managed to get it applied any ideas?
I don't see any trailing spaces in mypatch.patch
最满意答案
修补程序不适用的事实与末尾的空白无关。
该修补程序尝试删除y和z行,但z不存在于您要应用它的文件中( c/text.txt )。
类似于以下内容将适用于:
diff --git a/test.txt b/test.txt index 66455a1..1a0d96d 100644 --- a/test.txt +++ b/test.txt @@ -1,2 +1,4 @@ x -y \ No newline at end of file +z +p +q \ No newline at end of fileThe fact that the patch does not apply is not related to the trailing whitespace.
The patch tries to remove the y and z lines, but z does not exist in the file you're trying to apply it to (c/text.txt).
Something like the following would apply :
diff --git a/test.txt b/test.txt index 66455a1..1a0d96d 100644 --- a/test.txt +++ b/test.txt @@ -1,2 +1,4 @@ x -y \ No newline at end of file +z +p +q \ No newline at end of file更多推荐
发布评论