Home >System Tutorial >LINUX >How to solve the problem of automatic line break conversion in Git
I used to work on Linux, so I didn’t encounter the problem of file line separators when using Git. Now I suddenly switched to using Git on Windows and found that the files turned out to be Unix file line terminators when using git diff. Shows that all lines of the file have been modified.
The cause of this problem is Git's clever "newline automatic conversion" function. There are several ways to fix this problem
When installing "Git for windows", on the "Configuing the line ending conversions" page, change the default selection to "Checkout as-is, commit as-is"
If it has already been installed, you can also modify it through the command line, open "Git Bash" and enter
git config --global core.autocrlf false
You can also modify the ~/.gitconfig file in "Git Bash" and add or modify the following lines
autocrlf = false
If you use TortoiseGit, you can uncheck "AutoCrlf" in the Git configuration of setting, and then check "save as Global"
The above is the detailed content of How to solve the problem of automatic line break conversion in Git. For more information, please follow other related articles on the PHP Chinese website!