git line ends redux - Mac OS git with contributions for Windows user

风格不统一 提交于 2019-12-04 06:23:38

问题


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.

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)

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


回答1:


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

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

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



来源:https://stackoverflow.com/questions/21355458/git-line-ends-redux-mac-os-git-with-contributions-for-windows-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!