Recently want to put their own QT project synchronization to GitHub, but when the code from the warehouse check out when the compilation always appear some very wonderful error, at first thought is the source file encoding problem, changed the code after the problem or did not solve, I compared the two projects in the document, That's a surprise.
Windows line wrapping is \ r \ n, hexadecimal value is: 0D0A.
Linux line break is \ n, hexadecimal value is: 0A
Git is developed by the famous Linus and can only run on the *nix system at first, so it is recommended to store only UNIX-style line breaks. But it also takes into account cross-platform collaboration scenarios, and provides a "line break auto-transform" feature.
This feature is in Auto mode by default, and when you check out a file, it tries to replace the UNIX line break (LF) with the newline character (CRLF) of Windows, and when you commit the file, it tries to replace CRLF with LF. If the file you are on is a UTF-8 file that contains Chinese characters, then this "line break auto-Convert" feature is not working at the time of submission (but there is no problem with conversion processing at checkout)
Usegit config --global core.autocrlf
false可以关闭github换行自动转换功能
Or get rid of the. gitconfig file Add Autocrlf = False after [core]
The problem is solved! And you can have a nice code.
GitHub line break Auto-transform feature