虽然这个问题似乎像git add --interactive “Your edited hunk does not apply”的重复,但这不是因为该帖子没有回答这个问题,当然不是以一种可行的方式。
给出一个如下所示的文本文件:
line1
line2
line3
line4
我已提交并对其进行了编辑,使其看起来像这样:
line 1
line 5
line 3
line 4
现在我做一个git add --patch
并得到大块头:
@@ -1,4 +1,4 @@
line 1
-line 2
+line 5
line 3
line 4
Stage this hunk [y,n,q,a,d,e,?]?
我已经决定不要编辑,因此我将大块编辑为如下所示。我用空格(-
代替" "
,并用+
删除行。而且emacs会自动维护1,4
,因为这是相同的:
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -1,4 +1,4 @@
line 1
line 2
line 3
line 4
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
#
# If the patch applies cleanly, the edited hunk will immediately be
# marked for staging.
# If it does not apply cleanly, you will be given an opportunity to
# edit again. If all lines of the hunk are removed, then the edit is
# aborted and the hunk is left unchanged.
我明白了:
error: corrupt patch at line 10
Your edited hunk does not apply. Edit again (saying "no" discards!) [y/n]?
这是怎么回事?第10行说“#要删除'+'行,请将其删除”