【发布时间】:2016-10-28 01:05:40
【问题描述】:
尝试通过git add -p 和split 选项将大块拆分为较小的块,但整个文件显示为一个大块,我无法拆分它。
- 我可以编辑,但删除行会导致补丁失败。
-
git help add说我应该拆分,我记得使用过它,但在我当前的示例中,该选项没有出现在提示中。 - 当我选择选项帮助打印时,上面说我可以选择 s 来拆分:-[
Git 版本:1.9.1。 Xubuntu 14,哦,我的-zsh。大块不是一行,而是多行。任何想法为什么会这样?
编辑了更多数据,这里是控制台日志:
+last line of long text
Stage this hunk [y,n,q,a,d,/,e,?]? s
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 hunk and all later hunks in the file
d - do not stage this hunk nor any of the later 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
【问题讨论】:
-
我相信你必须先进入交互模式(
-i)才能使用split。 -
立即尝试了,但遗憾的是 - 效果相同。 IIRC git add -p 只是绕过用于选择选项的原始窗口,它直接跳转到修补程序。文档也这么说(现在检查)。不过还是谢谢。
-
使用 Git 2.17(2018 年第二季度)会更容易,它将显示更精确的帮助消息。见my answer below。