eclipse windows git 换行符问题


Set file encoding to UTF-8 and line-endings for new files to Unix, so that text files are saved in a format that is not specific to the Windows OS and most easily shared across heterogeneous developer desktops:

  • Navigate to the Workspace preferences (General:Workspace)
  • Change the Text File Encoding to UTF-8
  • Change the New Text File Line Delimiter to Other and choose Unix from the pick-list
然后Windows -> Preference -> General -> Editors -> Text Editors:

然后勾选Show whitespace characters复选框。
  • Note: to convert the line endings of an existing file, open the file in Eclipse and choose File : Convert Line Delimiters to : Unix
Tip: You can easily convert existing file by selecting then in the Package Explorer, and then going to the menu entry File : Convert Line Delimiters to : Unix  
CR回车 LF换行Windows/Dos CRLF \r\n
Linux/Unix LF \n
MacOS CR \r
解决方法是:打开命令行,进行设置,如果你是在Windows下开发,建议设置autocrlf为true2014/08/20 补充:如果你文件编码是UTF8并且包含中文文字,那还是把autocrlf设置为false,并且把所有文件转换为Linux编码(即LF\n),开启safecrlf检查。
一、AutoCRLF
#提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true  
#提交时转换为LF,检出时不转换
git config --global core.autocrlf input  
#提交检出均不转换
git config --global core.autocrlf false
二、SafeCRLF
#拒绝提交包含混合换行符的文件
git config --global core.safecrlf true  
#允许提交包含混合换行符的文件
git config --global core.safecrlf false  
#提交包含混合换行符的文件时给出警告
git config --global core.safecrlf warn
 
]]>