git format-patch / am问题(补丁不适用) [英] Problems with git format-patch/am (patch does not apply)

查看:394
本文介绍了git format-patch / am问题(补丁不适用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的repo上应用一些补丁,并且除非我指定params - ignore-space,否则获取消息补丁不适用 -change --ignore-whitespace 。有些补丁即使使用这些键也不能应用,它表示存在需要手动解决的冲突。 (但实际上没有任何冲突,自动合并必须解决这个问题)



我做了一个实验:从我的repo中的提交创建了一个补丁,将master重置为previous提交,试图从文件中应用补丁。相同的错误消息。



任何想法,为什么会发生这种情况?

UPD命令非常简单:

  git format-patch -o ../_patches 0f3bf7874c32b22256ae2d9dc00b1afd6464e43c 
git reset --hard 0f3bf7874c32b22256ae2d9dc00b1afd6464e43c
git am ../_patches /0001-test2.patch

(此ID指最后一次提交)

解决方案

看起来我找到了原因。存储库使用CRLF行结束符,但format-patch使用LF创建修补程序文件。当我用autocrlf = false从头创建一个repo并进行相同的实验时,我遇到了同样的问题。 (看起来像Git中的bug)

任何建议如何解决这个问题?



UPD我的解决方案是创建一个新的仓库autocrlf = true并重新导入来自两个存储库的所有更改。


I am trying to apply a few patches to my repo, and getting message patch does not apply unless I specify params --ignore-space-change --ignore-whitespace. Some patches can't be applied even with these keys, it says there are conflicts to be solved manually. (but actually nothing conflicts there, auto merge must had solved this)

I have done an experiment: created a patch from a commit in my repo, reset master to the previous commit, tried to apply patch from the file. The same error message.

Any ideas, why this might happen?

UPD the commands are very simple:

git format-patch -o ../_patches 0f3bf7874c32b22256ae2d9dc00b1afd6464e43c
git reset --hard 0f3bf7874c32b22256ae2d9dc00b1afd6464e43c
git am ../_patches/0001-test2.patch

(this id refers to the first commit before last)

解决方案

Aha! Looks like I've found the reason. The repository uses CRLF line endings, but format-patch creates patch files with LF's. When I create a repo from scratch with autocrlf=false and make the same experiment, I have the same problem. (looks like a bug in Git)
Any advise how to fix this?

UPD my solution was to create a fresh repository with autocrlf=true and re-import all changes from both repositories into it.

这篇关于git format-patch / am问题(补丁不适用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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