用`git add -p`解开两行 [英] Untangle two lines with `git add -p`
问题描述
#手动编辑模式 - 请参阅下方的快速编辑模式(foo)
{
bla();指导
@@ -280,6 +281,7 @@
- test(true);
+ removeThis();
+ test(false);
}
else
如何提交 test()
,并避免提交removeThis()?
每次我尝试手动编辑hunk时,git都会告诉我它并没有干净地应用。
我怎样才能仅仅改变test(),并避免提交removeThis()?
这很简单。
$ b
-
输入
add -i
模式,然后选择<$ c $按下 p Enter 键,即可打开c> 5:[p] atch 。 通过输入文件编号选择文件,然后按 Enter 开始编辑补丁。 $ b -
按 e 编辑您的大块(您似乎已通过
git add -p 代替成功到达) 。 -
用
removeThis()
完全 code> + 在开始处标记。别碰别的东西!所产生的文本应该看起来像是您正在提交的更改的补丁。 / strong>编辑器。
这个补丁很适用。我刚刚检查过。再次检查 - 也许这是另一个不适用的大块?
除此之外,您的,
符号靠近 +
/ -
看起来很可疑。也许,你的补丁程序
和 diff
程序有些不同步?尝试从大块中删除,
s。
I've got a file with the following changes:
# Manual hunk edit mode -- see bottom for a quick guide
@@ -280,6 +281,7 @@
if( foo )
{
bla();
- test( true );
+ removeThis();
+ test( false );
}
else
How can I commit the change for test()
only, and avoid committing removeThis() ?
Each time I try to edit the hunk manually git tells me it does not apply cleanly.
How can I commit the change for test() only, and avoid committing removeThis() ?
That's simple.
Enter
add -i
mode, then select5: [p]atch
by pressing pEnter.Choose your file by entering its number and press Enter to start editing patches.
Press e to edit your hunk (you seem to have succesfully reached here by doing
git add -p
instead).Delete the line with
removeThis()
completely, with+
sign at the beginning as well. Do not touch anything else! The resultant text should look like a patch for the change you're committing.Save the file and exit the editor.
The patch will apply well. I've just checked. Check again too--maybe it's another hunk that doesn't apply?
Other than that, your ,
symbols near the +
/-
look suspicious. Perhaps, your patch
and diff
programs are somehow out of sync? Try removing the ,
s from the hunk as well.
这篇关于用`git add -p`解开两行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!