如何避免git-apply改变行尾 [英] how to avoid git-apply changing line endings

查看:320
本文介绍了如何避免git-apply改变行尾的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 core.eol = crlf core.autocrlf = true core.safecrlf = true



当我从另一个 crlf repo和我的回购,受影响文件的所有行结束都改为 lf 。目前我正在使用这个补丁:

  git apply --ignore-whitespace mychanges.patch 

code>

(看起来我必须使用 - ignore-whitespace 来获取)



我目前的工作是在文件上运行 unix2dos 。有没有更好的方法让申请符合我的eol设置?

我不允许我的源代码管理系统控制我的线路结局。 Auto crlf是错误的,并且显示差异而没有烦人的^ M通过将core.whitespace设置为cr-at-eol来完成。现在差异输出将更好阅读。

I have a git repo set with core.eol=crlf, core.autocrlf=true and core.safecrlf=true.

When I apply a patch from another crlf repo and to my repo all the line endings for the effected file are changed to lf. Currently I'm applying the patch as so:

git apply --ignore-whitespace mychanges.patch

(It seems I have to use --ignore-whitespace to get the patch to successfully apply.)

My current work around is to run unix2dos on the file. Is there a better way of getting apply to conform to my eol settings?

解决方案

I would not allow my source control system to control my line endings. Auto crlf is false and showing diffs without the annoying ^M is done by setting core.whitespace to cr-at-eol. Now diff output will be nicer to read.

这篇关于如何避免git-apply改变行尾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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