git add --interactive“您编辑的大块不适用" [英] git add --interactive "Your edited hunk does not apply"

查看:400
本文介绍了git add --interactive“您编辑的大块不适用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用git add --interactive有选择地向索引添加一些更改,但是我不断收到您编辑的块不适用.请再次编辑..."消息.即使选择e选项,我也会收到此消息,并立即保存/关闭编辑器.换句话说,完全不编辑大块,补丁就不适用.

I'm trying to use git add --interactive to selectively add some changes to my index, but I continually receive the "Your edited hunk does not apply. Edit again..." message. I get this message even if I choose the e option, and immediately save/close my editor. In other words, without editing the hunk at all, the patch doesn't apply.

这是我正在使用的确切示例(我正在尝试整理一个小型演示):

Here's the exact example I'm using (I'm trying to put together a small demo):

原始文件:

first change
second change off branch
third change off branch
second change
third change
fourth change

新文件:

Change supporting feature 1
first change
second change off branch
third change off branch
second change
third change
fourth change
bug fix 1
change supporting feature 1

我试图显示如何使用git add --interactive仅将错误修复1"行添加到索引中.在文件上运行交互式添加,我选择补丁模式.它向我展示

I'm trying to show how to use git add --interactive to only add the "bug fix 1" line to the index. Running interactive add on the file, I choose the patch mode. It presents me with

diff --git a/newfile b/newfile
index 6d501a3..8b81ae9 100644
--- a/newfile
+++ b/newfile
@@ -1,6 +1,9 @@
+Change supporting feature 1
 first change
 second change off branch
 third change off branch
 second change
 third change
 fourth change
+bug fix 1
+change supporting feature 1

我用split响应,然后单击"no"以应用第一个块.第二个大块头,我尝试编辑.我最初尝试删除底线-没用.完全放弃大块头也不起作用,我也不知道为什么.

I respond with split, followed by "no" to apply the first hunk. The second hunk, I try to edit. I originally tried deleting the bottom line - that didn't work. Leaving the hunk alone completely doesn't work either, and I can't figure out why.

推荐答案

对于此特定示例,您需要调整大块中的行号.更改行:

For this particular example, you need to tweak the line numbers in the hunk. Change the line:


@@ -1,6 +2,8 @@

以使其改为:


@@ -2,7 +2,8 @@

这篇关于git add --interactive“您编辑的大块不适用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆