0

tldr:为什么我error: ... patch does not apply在编辑一个大块并删除一行时会得到,即使它看起来应该可以工作?

我正在编辑一个大块git add -p,我只想添加new line 1(而不是添加new line 2):

# Manual hunk edit mode -- see bottom for a quick guide
@@ -1 +1,3 @@
 first line
+new line 1
+new line 2
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.

我将 更改为+空格: new line 2

# Manual hunk edit mode -- see bottom for a quick guide
@@ -1 +1,3 @@
 first line
+new line 1
 new line 2
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.

但这给出了错误:

error: patch failed: myfile:1
error: myfile: patch does not apply
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]? 

问题是什么?

4

1 回答 1

0

而是删除该行。

更改+为空格 不是正确的操作。 根据 git ( ) 给出的指示,需要删除
# To remove '+' lines, delete them. new line 2

# Manual hunk edit mode -- see bottom for a quick guide
@@ -1 +1,3 @@
 first line
+new line 1
# (^^^ note that "new line 2" has been deleted ^^^)
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
于 2020-07-01T15:59:39.543 回答