使用git应用diff文件 [英] Applying a diff file with git

查看:1703
本文介绍了使用git应用diff文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图使用diff文件到我的git dev分支。我想申请的差异是这个:,建议删除rebase-apply文件夹在分支.git文件夹中。所以我这样做,然后我再次得到了无效的电子邮件错误(尽管我已经改变了两种格式的HTML格式)

p>我也有同样的问题:

  fatal:git apply:bad git-diff  -  expected / dev / null on line 47 

然而第47行显示 --- / dev / null 。我发现的问题是行结束符是Windows格式而不是UNIX格式。在Notepad ++中将行结束符转换为UNIX格式解决了我的问题。


So I was trying to use apply a diff file to my git dev branch. The diff I wanted to apply was this one here: https://github.com/mbabker/joomla-cms/compare/JHtml_move.patch

I used git apply PATH_TO_PATCH.patch

Now on trying to apply it I get a load of errors cumulating with a

fatal: git apply: bad git-diff - expected /dev/null on line 47

Thing is line 47 reads --- /dev/null

I saw on another forum somebody say there was a trailing white space after the /dev/null part but there isn't.

In case its any help I'm also being thrown errors of trailing white spaces on lines 9, 10, 11, 12 and 13 - despite their NOT being any trailing white spaces.

In any case the diff is being generated by git - I'm just copying and pasting it into notepad.

I've also tried using curl https://github.com/mbabker/joomla-cms/compare/JHtml_move.patch | git am but that just gives an error without specifying location.

Any ideas as to why its giving an fatal error when the line actually exists????


Update to @IvanZuzak I tried adding in the git am --ignore-space-change --ignore-whitespace PATH_TO_PATCH.patch however I got first of all (as this was the downloaded patch) an error saying the email was invalid (it had been converted to html code) so I tried to fix that but it kept throwing it up every now and again. Then it said previous rebase directory PATH_TO_GITHUB_BRANCH/.git/rebase-apply still exists but mbox given.. So I found this which suggested removing the rebase-apply folder in the branches .git folder. So I did that and then I got the invalid email error again (despite I'd changed both ones away from the html formatted)

解决方案

I also had the same problem:

fatal: git apply: bad git-diff - expected /dev/null on line 47

Yet line 47 reads --- /dev/null. The problem I found was that the line endings were in Windows format instead of UNIX format. Converting the line endings to UNIX format in Notepad++ fixed the problem for me.

这篇关于使用git应用diff文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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