我有这个大块头,我想对其进行编辑,以便忽略对 uuid
的更改。
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -43,4 +44,7 @@
"date-fns": "^2.23.0",
- "uuid": "^8.3.2"
+ "imask": "^6.1.0",
+ "uuid": "^8.3.2",
+ "validator": "^13.6.0",
+ "vest": "^3.2.5"
}
}
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
到目前为止,我的想法是执行以下操作,这意味着 hunk header 不需要更改(对吧?)。
# Manual hunk edit mode -- see bottom for a quick guide.
@@ -43,4 +44,7 @@
"date-fns": "^2.23.0",
"uuid": "^8.3.2"
+ "imask": "^6.1.0",
+ "validator": "^13.6.0",
+ "vest": "^3.2.5"
}
}
# ---
# To remove '-' lines, make them ' ' lines (context).
# To remove '+' lines, delete them.
# Lines starting with # will be removed.
但是,保存更改并退出后,我仍然得到以下信息:
error: patch failed: package.json:43
error: package.json: patch does not apply
在这一点上,我很困惑,我不确定要尝试什么。起初我以为是缺少空格,因为我的 VIM 配置用制表符替换了它,但手动添加空格也不能解决问题(在 -
行中)。
到目前为止,我唯一的猜测是标题有问题,但它应该正确排列,对吗?我仍然在这两种情况下添加 7
行,4
保持不变。
我已经查看了 similar questions但还没有找到解决此类问题的方法。
我可以尝试使用 GUI,但我想尽可能避免使用它。
有什么想法吗?我将不胜感激。
最佳答案
看来您遇到了与 this other user 相同的问题: 如果你在 git add -p
中拆分一个大块,有一个错误会阻止应用“手动编辑”一个子大块。
解决方法很简单:搁置当前版本的 package.json
,然后将该文件编辑为您要提交的版本。
同样值得注意的是:git gui
提供了一个功能完美的“stage this line”操作——当您右键单击右侧 Pane 中显示的 diff 中的任何行时。
关于git - 手动编辑 git add --patch 导致错误(补丁失败),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69078859/