Jan-14, 2024 · 3min
change languageLearn how to configure Git on Windows to use LF line endings instead of CRLF, including global settings and .gitattributes configuration for consistent cross-platform development
When writing the test of Debbl/eslint-config
await Promise.all(
files.map(async (file) => {
let content = await fs.readFile(join(target, file), 'utf-8')
const source = await fs.readFile(join(from, file), 'utf-8')
if (content === source) {
content = '// unchanged\n'
}
await expect.soft(content).toMatchFileSnapshot(join(output, file))
}),
)
In github action, there is a test using multiple systems
strategy:
matrix:
node: [lts/*]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false
When testing windows, there is always an error test, the input and output do not match, and after testing, it is found that the eol
of windows default when git is downloaded is crlf
So I searched for how to set eol
to lf
in GitHub Action actions/checkout#135
Finally, add the following command ci.yml
Windows can be set to lf
through the following command
git config --global core.autocrlf false
git config --global core.eol lf
- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf
.gitattributes
* text=auto eol=lf