git hunk edit mode - how to remove a '-' line?

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

I simply don't understand what make them ' ' lines means. How to apply + bbb only but not - aaa?

11548 次浏览

make them ' ' lines意味着你需要用一个 (空格)代替线前面的 -

像这样的大块头:

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

会变成这样的内容:

bbb
ccc

要保持一行标记为删除(前缀为 '-') ,将其转换为与上面的 unchanged行前缀相同的行(这样它将保持不变) :

+ bbb
aaa
ccc

当大块被应用时,内容看起来是这样的:

bbb
aaa
ccc