我通常使用git add -p添加更改,并且很多时候会有带有多个代码块的大块,用空行分隔。
但是,Git不会再使用Hunk了,我不得不求助于手动编辑。
如何增加大块的粒度,使每个代码块都在单独的大块中?
编辑:这是一个不同于Git: show more context when using git add -i or git add -e?的问题,因为我不想增加每个hunk的上下文,而是增加hunk的数量。

最佳答案

这是不可能的,
以下是您可以在add -p中执行的选项:

y - stage this hunk
n - do not stage this hunk
q - quit, do not stage this hunk nor any of the remaining ones
a - stage this and all the remaining hunks in the file
d - do not stage this hunk nor any of the remaining hunks in the file
g - select a hunk to go to
/ - search for a hunk matching the given regex
j - leave this hunk undecided, see next undecided hunk
J - leave this hunk undecided, see next hunk
k - leave this hunk undecided, see previous undecided hunk
K - leave this hunk undecided, see previous hunk
s - split the current hunk into smaller hunks
e - manually edit the current hunk
? - print help

一旦您使用了s它将选择可以视为独立更改的代码块。如果你想把它分割得更大,你就必须使用e来编辑这个模型,然后把它添加回舞台区域。
总结:
要拆分大块,请使用s标志。
如果需要将其拆分为更小的块,则需要使用e选项手动编辑它。

09-27 02:35