- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用git add --interactive
有选择地向我的索引添加一些更改,但我不断收到“您编辑的大块不适用。再次编辑...”消息。即使我选择 e 选项,我也会收到此消息,并立即保存/关闭我的编辑器。换句话说,如果根本不编辑该 block ,则该补丁不会应用。
这是我正在使用的确切示例(我正在尝试组合一个小演示):
原始文件:
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
仅将“bug fix 1”行添加到索引中。在文件上运行交互式添加,我选择补丁模式。它向我展示了
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”来应用第一个 block 。第二个大块头,我尝试编辑。我最初尝试删除底线 - 但没有成功。完全不理睬这个大块头也行不通,我不明白为什么。
最佳答案
就像 this git-add post 中那样吗? ?
Manually editing the hunk is immensely powerful, but also a bit complicated if you've never done it before.
The most important thing to keep in mind: The diff is always indented with one character in addition to whatever other indentation is there.
The character can either be:
- a space (indicates an unchanged line),
- a
-
indicating that the line was removed,- or a
+
indicating that the line was added.Nothing else. It must be either a space, a - or a +. Anything else, and you'll get errors
(there's no character for a changed line, since those are handled by removing the old line, and adding the changed one as new).Since you've got the diff open in your favorite text editor (you did configure Git to use your favorite text editor, right?), you can do whatever you want - as long as you make sure the resulting diff applies cleanly.
And therein lies the trick. If you've never done this before, Git will tell you "Your edited hunk does not apply. Edit again?" so often, you'll start to hate yourself for your inability to figure this out, even though it seems so easy (or Git because it can't figure out what you want).
One thing that tripped me up quite often was that I forgot the one character indent.
I'd mark a line with a - to be removed, but in most text editors that inserts a-
, it doesn't overwrite the space that was there before. This means you're adding an additional space to the whole line, which in turn means the diff algorithm can't find/match the line in the original file, which in turn means Git will yell at you.The other thing is that the diff still has to make sense. "Sense" means that it can be applied cleanly. Exactly how you create a sensible diff seems to be a bit of an dark art (at least to me right now), but you should always keep in mind how the original file looked like, and then plan your -s and +s accordingly. If you edit your hunks often enough you'll eventually get the hang of it.
另请参阅 commit on git add -p .
Ortomala Lokni的answer指Joaquín Windmüller 博客文章“ Selectively select changes to commit with git (or Imma edit your hunk) ”
Git 想要做的不是计算行数,而是在应用所述编辑后的 block 之前合并重叠的 block (当编辑 block 时)。
那是discussed mid-2018 ,并且会避免这样的情况:
if you split a hunk, edit the first subhunk, transforming a trailing context line to a deletion then if you try to stage the second subhunk, it will fail.
关于interactive - git add --interactive "Your edited hunk does not apply",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3268596/
我有 Site {{$url}} 和 $(function(){ $('#pencil').click
我在每一行都有一个编辑按钮,我已经设置了 defaultColDef: { editable: false, } 在网格选项中 当我点击编辑按钮时,我希望该行处于编辑模式。如果我设置
我在每一行都有一个编辑按钮,我已经设置了 defaultColDef: { editable: false, } 在网格选项中 当我点击编辑按钮时,我希望该行处于编辑模式。如果我设置
我有一个 html 文件,我想编辑其中的字段。以下是我的 html 代码: ID GROUP NAME GROUP DESCRIPTION IS A
我希望管理员能够编辑普通用户无法编辑的字段。例如作者或订阅者等。 我试过这个:Django admin: How to display a field that is marked as editab
如何将PS文件中间的数据移动到Mainframe的左侧?有什么快捷命令吗? 我有一个数据集,第 13 列有数据,必须将其移动到第 11 列,任何短键都可以移动它。 想要将 DS 中的其余行作为第一行对
我在 div 中有一个可编辑元素,它本身是可点击的。每当我单击 x-editable anchor 元素时,单击会在 DOM 中冒泡并触发对父 div 的单击。我怎样才能防止这种情况发生?我知道可以使
我有一个类似这样的模型: class Product(models.Model): third_party_id = models.CharField(max_length=64, blank
我有一个包含 2 个可编辑文本字段的页面 {{creator.name}} Tell us about yourself in less than 100 words
这是我的架构: id: 'EntryCode', fields: { EntryCode: {editable: true, validation: {required: true}, nul
有人可以帮助确定这个问题 - http://jsfiddle.net/xBB5x/8823/ 我正在尝试实现 x-editable (bootstrap 2) typeahead 功能。 上面的 js
如果我使用例如 g_object_set (renderer, "background", "red", "background-set", FALSE, NULL); 对于文本渲染器, TreeVi
我在创建和编辑页面上都使用了 Angular 文件,但我想知道是否有办法阻止用户在/edit 页面上编辑 Geo Segment 的名称。 geo-region-detail.html: G
我正在尝试向 QListWidget 添加一个项目,选择该项目,然后开始编辑新项目。 该项目被添加,它被选中,但该行没有被引入 QLineEdit,或者它试图使用的任何东西。 这是我的小部件的代码,相
我有一个表格,其中的单元格和列中有多个值。当用户单击 TD 单元格上的任意位置时,我希望它: 成为文本区域 将当前文本粘贴到文本区域 在其下方放置一个取消按钮 一旦按下取消按钮,我希望一切都变回以前的
在我的程序中,会有一个机会编辑框,它可以更改“掉率”或“获胜率” 但我想将其更改为如果用户输入大于 100 的数字并点击编辑框,编辑框文本将变回 100。 我不知道如何实现这个。 最佳答案 看看下面的
我想创建我的编辑表单,以便它将当前用户信息简单地显示为文本,而不是在文本字段中,当用户单击文本时,它将变成文本字段,用户可以编辑他的信息。仅当用户单击提交按钮时,更改才会反射(reflect)在数据库
我有一个 QTreeWidgetItem 添加到 QTreeWidget: QTreeWidgetItem* item = new QTreeWidgetItem(ui->trwPairs); ite
我检查了最新的 Dropbox 和 Excel for iOS。在 Dropbox 中,我们有一个编辑按钮。单击它会打开 Excel 的扩展程序,您可以在其中编辑文件。 保存后,更改也会反射(refl
我目前正在使用pycord创建一个Python语言的不和谐机器人。我有一个发送消息的命令,其中嵌入了两个字段。一个名为Yes,值为0;另一个名为No,值也为0。在选择菜单中,我创建了两个选项。选项是和
我是一名优秀的程序员,十分优秀!