git hunk编辑模式 - 如何删除' - '行?

时间:2012-05-24 04:41:40

标签: git patch

+ bbb
- aaa

# ---
# 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.

我根本不明白make them ' ' lines的含义。如何仅应用+ bbb而不是- aaa

2 个答案:

答案 0 :(得分:75)

make them ' ' lines表示您需要使用-(空格)替换该行前面的

答案 1 :(得分:11)

像这样的大块头:

+ bbb <-- line added
- aaa <-- line deleted
  ccc <-- line unchanged

会变成这样的内容:

bbb
ccc

要保留标记为删除的行(前缀为'-'),请将其转换为与上面的unchanged行具有相同前缀的行(因此它将保持不变):

+ bbb
  aaa
  ccc

应用大块时,内容将如下所示:

bbb
aaa
ccc