增加git大块粒度 [英] Increase git hunk granularity
问题描述
我通常使用git add -p
添加更改,而且很多时候很多大块都带有几行代码,用空行分隔.
I usually add changes with git add -p
, and many times there are large hunks with several blocks of code, separated by blank lines.
但是,git不会再split
大块头了,我不得不求助于手动编辑.
However, git won't split
the hunk any further, and I have to resort to manual editing.
如何增加块的粒度,以使每个代码块都位于单独的块中?
How can I increase the granularity of the hunks, such that every block of code will be in a separate hunk?
This is a different question from Git: show more context when using git add -i or git add -e?, since I'M not looking to increase the context around each hunk, but rather increase the number of hunks.
推荐答案
无法完成,
这些是您可以在add -p
中执行的选项:
These are the options you can do within 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
编辑块,然后将其重新添加到舞台区域.
Once you use the s
it will pick the chunk of code which can be considered as a standalone change. If you want to split it even more you will have to use the e
to edit the hunk and then add it back to the stage area.
要拆分大块,请使用s
标志.
如果需要将其拆分成更小的块,则需要使用e
选项手动对其进行编辑.
To split hunks you use the s
flag.
If you need to split it into even smaller chunks you will need to manually edit it using the e
option.
这篇关于增加git大块粒度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!