Multiplatform development and autocrlf option in Git

不问归期 提交于 2019-12-24 10:23:51

问题


I am currently using Git and all is well on my Windows PC. I have my autocrlf set to true which according to this is correct

https://help.github.com/articles/dealing-with-line-endings

Actually I have no complaints, it seems to work very well, there are some warning now and again but I normally ignore them.

But what does this actually do then? Does this add CR/LF when doing a PULL and then change CRLF to LF when doing a push?

So "ALWAYS" in the repo there are files with "ONLY" LF and not CRLF?

I am about to start development in the same repository with a MAC OS X and Linux, now this is where I get confused, according to GitHub it states that for Windows set Autocrlf to TRUE.

But on Linux / MAC OS X, should I do the same? Linux I know doesn't use the CRLF.

Update

I see various comments on Stack Overflow to not use it as true, but of course I am using 3 types of systems so I suppose this is why it's recommended here?

And Linux is recommended too? but it would never make crlf.

So I suppose the case is, always leave it as true, just in case?


回答1:


Set autocrlf to true on OS X as well. It will do the right thing. (In fact, you can also set it on Linux and it will again do the right thing.)


But what does this actually do then? Does this add CR/LF when doing a PULL and then change CRLF to LF when doing a push?

Yes. It transforms files into the local native line ending format when they're checked out locally, and then when they're committed they're automatically transformed back into the canonical line ending format (LF).




回答2:


This might help answer some of your questions.

Basically, this only really matters if you're using an editor that cannot deal with line endings properly, or one that complains a lot (like Visual Studio).



来源:https://stackoverflow.com/questions/12031212/multiplatform-development-and-autocrlf-option-in-git

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