2015-09-08 52 views
4

我有3個文件a\test.txtb\test.txtc\test.txt尾隨空格。補丁不適

a\test.txt

x 
y 
z 

b\test.txt

x 
z 
p 
q 

c\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

回答

2

補丁不適用不涉及尾隨空白的事實。

補丁嘗試刪除yz線,但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 file