Configure Git's line endings

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 (\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.

# 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 endings

More like this

  • Collection · 13 articles

    Git Configuration

    Create and manage git configurations with this article collection of simplified git documentation and tips.

  • Git ·

    Add a Git commit message template

    If you want your team to follow a common format for commit messages, you can set up a commit message template to make it easier.

  • Git ·

    Merge a branch in Git

    Learn how to merge a branch in Git with or without creating a merge commit, depending on your team's workflow.