Questions about Git CRLF lf end

Source: Internet
Author: User

In the process of using Git, if our project is a cross-platform development then CRLF processing might be a headache, and there might be some puzzling questions:

A file that one of our developers submitted on Linux

When you pull down from windows, you don't make any changes to view its status, it's already modifed.

Even if you use Git checkout-f to restore the file, its state is still modified,

Really depressed ... Later, I found out it was CRLF.

As we all know, on Windows is CRLF as a line of Terminator, while Linux is LF as line terminator

Autocrlf is provided in Git and can be used to automatically convert CRLF, which can be set to True,false,input

Msysgit on Windows defaults to Autocrlf to true so that the line terminator CRLF is converted to LF on commit, and LF is converted to CRLF when the code is checked out, the code submitted from the Windows platform is guaranteed to be a LF as the line terminator

On the Linux platform, the GIT default setting is Autocrlf to false, that is, it does not automatically process CRLF so there is a problem if we upload a file on Windows to Linux and submit

Then, the code submitted to the warehouse will be CRLF to the line, which will cause us to see the change in the status of the file on Windows will be modified to solve this problem has the following 2 ways:

  1. Set AUTOCRLF to input on Linux, so git converts CRLF to LF when it commits, does not convert when checked out
  2. For files that are copied directly from Windows to Linux, first convert it to a Linux format before committing

Questions about Git CRLF lf end

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.