puddlejumper26 / blogs

Personal Tech Blogs
4 stars 1 forks source link

git convert CRLF to LF #40

Open puddlejumper26 opened 4 years ago

puddlejumper26 commented 4 years ago

Sometimes we have problem with the CRLF and LF things, it is very common.

And it is normally the problem with Git. When we have

taken from this website

https://gist.github.com/ajdruff/16427061a41ca8c08c05992a6c74f59e

first we need to set the crlf and lf to the correct value with terminal

git config --global core.autocrlf false
git config --global core.autolf true

This is for the global, therefore we need to also consider about the settings in other places.

we could find them throug git config --list it will display as following

core.symlinks=false
core.autocrlf=true
core.fscache=true
color.diff=auto
color.status=auto
color.branch=auto
color.interactive=true
help.format=html
...

If we don't know where the default git file is, we could use git config --list --show-origin it will displays as following

file:"C:\\ProgramData/Git/config"    core.symlinks=false 
file:"C:\\ProgramData/Git/config"    core.autocrlf=true 
file:"C:\\ProgramData/Git/config"    core.diff=false
...

Then we could find and open the config throug the path, to change as following

core.autocrlf = false
core.autolf = true

Further explanation could be found here (https://www.jianshu.com/p/ec9564fe1c2b)

SilasVM commented 1 year ago

Hey, I found this really helpful. Just for reference however 'autolf' is not a built in git attribute. When you type 'git config --global core.autolf true' you make a false attribute that doesn't do anything. It's enough to simple type 'git config --global core.autocrlf false'