如果 git-am 因“不匹配索引”而失败该怎么办?
我正在尝试使用其他人使用 git-format-patch 创建的 git 补丁。该补丁是针对 HEAD 后面的一次提交而制作的,但据我了解,这应该不重要。当我运行 git am 0001.patch 时,出现错误:
error: source.c: does not match index
我不太熟悉 git 补丁的格式,但索引似乎不匹配,但源确实匹配。
解决这个问题的最佳方法是什么?手动更改索引以匹配?或者我应该git-apply
然后在提交时复制作者和描述信息?
I'm trying to apply a git patch created by someone else with git-format-patch
. The patch was made against one commit behind HEAD, but as I understand it this shouldn't matter. When I run git am 0001.patch
, I get the error:
error: source.c: does not match index
I'm not too familiar with the format of git patches, but it does seem that the indexes don't match, however the source does match.
What's the best way to fix this? Manually change the indexes to match? Or should I git-apply
and then copy the author and description information when I commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
来自JC Hamano(Git 维护者)本人,内容是:
在最近的 Git 版本中,您可以中止:
然后:
注意:脏树的来源之一可能是
autocrlf
设置(例如 msysgit 问题 81) ,所以请确保将其设置为 false.其他差异来源:
core.whitespace< /代码>设置
。
OP 在评论中提到:
注意:在最近的 Git1.7.2 发行说明< /a>:
From J.C. Hamano (Git maintainer) himself, this is about:
With recent Git release, you can abort:
Then:
Note: one source of dirty tree can be the
autocrlf
setting (like in this msysgit issue 81), so make sure to set that to false.Other source of discrepancy:
core.whitespace
setting.The OP mentions in the comment:
Note: in the recent Git1.7.2 Release Notes:
对我来说,我使用的是旧版本的 git (centOS-6 distro)。
我可以通过执行以下操作来解决此问题:
git update-index --refresh
git am ${patch_filename}
以了解有关其工作原理的更多信息。请检查 原始来源在这里:
“
我有点惊讶我们没有完成“预先刷新一次”
过去 5 年里没有人遇到过这种情况。看来
我从 git-applymbox 继承了这种行为;-)
在开始时和重新启动时刷新一次是明智的
与“am --resolved”。
”
for me i'm on an older versions of
git
(centOS-6 distro).I was able to fix the issue by doing:
git update-index --refresh
git am ${patch_filename}
to read more on why this works. please check the original source here:
"
I am kind of surprised that we have not done the 'refresh once upfront'
already and nobody ever run into this for the past 5 years. It seems that
I inherited that behaviour from git-applymbox ;-)
It is sensible to refresh once at the beginning and also when restarting
with "am --resolved".
"