git line 结束 redux - 为 Windows 用户贡献的 Mac OS git [英] git line ends redux - Mac OS git with contributions for Windows user

查看:27
本文介绍了git line 结束 redux - 为 Windows 用户贡献的 Mac OS git的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Mac OS X 上进行开发.我有一个用户正在贡献带有 CRLF 行结尾的代码.他目前不使用git.我创建了一个分支,然后将我的工作树切换到它.我将他的文件复制到工作树中.当我尝试暂存文件时,我收到错误 fatal: CRLF will be replace by LF in pcb-gcode.ulp.我经历了无数的帖子并尝试了建议(例如 .gitattributes & git reset),唯一的解决方案似乎是使用 sfk 或类似的方法在我从他.

I do development on Mac OS X. I have a user who is contributing code with CRLF line endings. He currently does not use git. I create a branch, then switch my working tree to it. I copy his file into the working tree. When I try to stage the file, I receive the error fatal: CRLF would be replaced by LF in pcb-gcode.ulp. I've been through endless posts and tried suggestions (such as .gitattributes & git reset) and the only solution seems to be to use sfk or similar to change the line endings when I get the file from him.

有没有办法让 git 在登台和提交时将他的 CRLF 行结束更改为 LF,如果我将分支签出到我的工作树,则使用 LF?似乎有一个选项可以让 git 将行尾识别为行尾,并在我检查时给我适合我的操作系统的内容.

Is there a way to have git change his CRLF line ends to LF when staging and committing, and use LF if I checkout the branch to my working tree? It seems that there would be an option to have git just recognize a line ending as a line ending and give me what is appropriate for my OS when I check it out.

git config --global -l (excerpt)
core.autocrlf=input
core.safecrlf=true

git config --local -l
(nothing relevant)

我正在使用 SourceTree,远程存储库托管在 Assembla 上,以防万一.

I'm using SourceTree and the remote repo is hosted on Assembla, in case that is pertinent.

推荐答案

我觉得,你可以试试新的(1.7.2+)core.eol

I think, you can try new (1.7.2+) core.eol

设置在文件工作目录中使用的行尾类型设置了 text 属性.替代方案是 'lf'、'crlf' 和'native',使用平台的本地行结尾.默认的值是原生的

Sets the line ending type to use in the working directory for files that have the text property set. Alternatives are 'lf', 'crlf' and 'native', which uses the platform's native line ending. The default value is native

并且不要使用有缺陷和不明显的core.autocrlf

And don't use buggy and not-obvious core.autocrlf

这篇关于git line 结束 redux - 为 Windows 用户贡献的 Mac OS git的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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