PhpStorm + GIT line endings changing from LF to CR

2020-07-06 08:17发布

I have set in my PhpStorm line endings to LF but when I commit to github, sometimes I see some of the files again appear with CRLF line ending (I work on Windows).

It happens with the same files I've edited and nobody edited them between my commits/pushes to repository. It's very irritating and I need to often change line endings to the same file. What could it be and how to fix it?

I also have checked option "Warn if CRLF line separators are about to be commited"

EDIT

My local git config is this:

[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = https://github.com/*
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "develop"]
    remote = origin
    merge = refs/heads/develop

My global config is this:

[user]
    name = *
    email = *
[core]
    autocrlf = false

My systemwide config is this:

[core]
    symlinks = false
    autocrlf = false
[color]
    diff = auto
    status = auto
    branch = auto
    interactive = true
[pack]
    packSizeLimit = 2g
[help]
    format = html
[http]
    sslCAinfo = /bin/curl-ca-bundle.crt
[sendemail]
    smtpserver = /bin/msmtp.exe

[diff "astextplain"]
    textconv = astextplain
[rebase]
    autosquash = true

And my GIT settings in PhpStorm:

My Git Settings in PhpStorm

3条回答
贪生不怕死
2楼-- · 2020-07-06 08:26

You can check if this Git setting can help:

git config --global core.autocrlf false

I usually recommend keeping core.autocrlf to false (there are only a few reason to set it to true).

Check also if you have any .gitattributes files with a core.eol directive in it.

查看更多
Ridiculous、
3楼-- · 2020-07-06 08:28

git config --global core.autocrlf input will ensure LF only for all git projects.

查看更多
我只想做你的唯一
4楼-- · 2020-07-06 08:32

After tests it was obviously not PhpStorm issue but GIT config issue.

It seems that on Windows it's necessary to set:

git config --global core.autocrlf input

but also

git config --global core.eol lf

to make it work.

查看更多
登录 后发表回答