Skip to content

Instantly share code, notes, and snippets.

@meteorlxy
Last active December 9, 2020 15:51
Show Gist options
  • Save meteorlxy/51909fce26817a5a7fd4058c8c64fcfd to your computer and use it in GitHub Desktop.
Save meteorlxy/51909fce26817a5a7fd4058c8c64fcfd to your computer and use it in GitHub Desktop.
Correct end of line
# @see https://editorconfig.org/
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
# @see https://git-scm.com/docs/gitattributes
# @see https://help.github.com/articles/dealing-with-line-endings
* text eol=lf
*.txt text eol=crlf
*.png binary
*.jpg binary
*.jpeg binary
*.ico binary
*.tff binary
*.woff binary
*.woff2 binary
{
"editor.detectIndentation": false,
"editor.insertSpaces": true,
"editor.tabSize": 2,
"files.eol": "\n"
}

see https://stackoverflow.com/questions/2517190/how-do-i-force-git-to-use-lf-instead-of-crlf-under-windows

git config --global core.eol lf
git config --global core.autocrlf input
git config --global core.safecrlf true

git rm -rf --cached .
git reset --hard

AutoCRLF

#提交时转换为LF,检出时转换为CRLF
git config --global core.autocrlf true

#提交时转换为LF,检出时不转换
git config --global core.autocrlf input

#提交检出均不转换
git config --global core.autocrlf false

SafeCRLF

#拒绝提交包含混合换行符的文件
git config --global core.safecrlf true

#允许提交包含混合换行符的文件
git config --global core.safecrlf false

#提交包含混合换行符的文件时给出警告
git config --global core.safecrlf warn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment