运行'git apply'时出错 [英] Error in running 'git apply'

查看:730
本文介绍了运行'git apply'时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您可以告诉我,当我尝试
'git apply-patch'时,我该如何解决'patch does not apply'错误?

  $ git apply 0001-my.patch 
错误:补丁失败:test.xml:114
错误:text.xml:补丁不适用

我的本​​地目录中有'test.xml'。当我做'git status'时,它显示我没有本地更改。



感谢您的任何帮助。



  git am -3 $ b 

$ b




当修补程序不能干净地应用时,回退3路合并( git am






qneill 提及评论 git apply 现在有一个 - 3way 选项


你现在可以在没有的情况下应用你的补丁以减少上下文。

因为它会在索引中留下冲突的一半,并让您手动解决工作树中的冲突, - 3way 意味着 - index ,并且不能与 - cached - 拒绝

您可以在 git1.7.12发行说明(2012年8月,比原始问题稍微少了3年)
$ b $ b


git apply 学会摆动基础版本并在补丁不完全适用时执行三路合并您拥有的版本。



Can you please tell me how can I resolve the 'patch does not apply' error when I try to 'git apply-patch'?

$ git apply 0001-my.patch
error: patch failed:test.xml:114
error: text.xml: patch does not apply

I do have 'test.xml' in my local directory. And when I do 'git status', it shows I don't have local changes.

Thank you for any help.

解决方案

You can try a:

git am -3

When the patch does not apply cleanly, fall back on 3-way merge (git am doc)


qneill mentions in the comments that git apply now have a --3way option:

you can now apply your patches without having to reduce context.
As it will leave the conflicted halves in the index and let you manually resolve conflicts in the working tree, "--3way" implies "--index", and cannot be used with "--cached" or "--reject".

You can see it in the git1.7.12 release note (August 2012, a bit less than 3 years after the original question)

"git apply" learned to wiggle the base version and perform three-way merge when a patch does not exactly apply to the version you have.

这篇关于运行'git apply'时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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