snippetjavascriptTip
Configure Git's line endings
Viewed 0 times
configureendingslinegit
Problem
If you're working with a team that uses different operating systems, you might run into issues with line endings. Windows uses a different line ending (
Luckily, Git provides a way to configure line endings for a repository. By setting the
You can simply run
\r\n) compared to UNIX systems (\n). This can cause problems when sharing files between different systems.Luckily, Git provides a way to configure line endings for a repository. By setting the
core.eol configuration, you can specify whether to use UNIX (\n) or DOS (\r\n) line endings in your repository.You can simply run
git config core.eol [lf | crlf] to configure the line endings for your repository. lf stands for UNIX line endings, while crlf stands for DOS line endings.Solution
# Usage: git config core.eol [lf | crlf]
git config core.eol lf
# Configures to use UNIX line endings
git config core.eol crlf
# Configures to use DOS line endingsYou can simply run
git config core.eol [lf | crlf] to configure the line endings for your repository. lf stands for UNIX line endings, while crlf stands for DOS line endings.Code Snippets
# Usage: git config core.eol [lf | crlf]
git config core.eol lf
# Configures to use UNIX line endings
git config core.eol crlf
# Configures to use DOS line endingsContext
From 30-seconds-of-code: line-endings
Revisions (0)
No revisions yet.