Home >System Tutorial >LINUX >How to solve the problem of automatic line break conversion in Git

How to solve the problem of automatic line break conversion in Git

WBOY
WBOYOriginal
2024-06-28 08:11:081216browse

解决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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn