Pregunta

I pushed a file in DOS Format to git (\r\n at the end of the line)
But when i clone the git repo on my build Server (Ubuntu) the file is in the Unix Fileformat (\n at the end of the line)

How can I change this behaviour?
Git man and search didn´t help me.

¿Fue útil?

Solución

Git can handle Windows behavior of using both a carriage-return character and a linefeed character for newlines by auto-converting CRLF line endings into LF when you commit, and vice versa when it checks out code onto your filesystem. You can turn on this functionality with the core.autocrlf setting. If you’re on a Windows machine, set it to true — this converts LF endings into CRLF when you check out code:

$ git config --global core.autocrlf true

If you’re on a Linux or Mac system that uses LF line endings, then you don’t want Git to automatically convert them when you check out files; however, if a file with CRLF endings accidentally gets introduced, then you may want Git to fix it. You can tell Git to convert CRLF to LF on commit but not the other way around by setting core.autocrlf to input:

$ git config --global core.autocrlf input

This setup should leave you with CRLF endings in Windows checkouts but LF endings on Mac and Linux systems and in the repository.

If you’re a Windows programmer doing a Windows-only project, then you can turn off this functionality, recording the carriage returns in the repository by setting the config value to false:

$ git config --global core.autocrlf false

Otros consejos

Setting the default line ending in GIT would solve your problem.

git config --global core.autocrlf true

A quick google search on setting GIT line endings gave me this. https://help.github.com/articles/dealing-with-line-endings#platform-windows

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top