Updated on 2023-07-14 GMT+08:00

Setting the Line Ending Conversion

Background

Different operating systems may use different line endings. Therefore, if you open a file created in an operating system different from yours, the file may be displayed incorrectly. This problem may also occur when you use version control systems.

Procedure

  1. (Optional) By default, core.autocrlf is set to false in Git. Perform the following operations to enable Git to identify and convert the line endings for text files:
    • On Windows

      Set core.autocrlf to true. All text files in the local repository use LF line endings whereas those checked out to the working directory use CRLF line endings.

    • On Linux

      Set core.autocrlf to input. When files are imported to the local repository, Git auto-converts line endings from CRLF to LF. No conversion is performed when files are checked out from the local repository to the working directory.

  2. Set core.autocrlf to true to enable auto-conversion of line endings.
    git config --global core.autocrlf true