CRLF and LF

Source: Internet
Author: User

Directory:

    1. What is CRLF and LF
    2. Why explore CRLF and LF
    3. Three different ways of handling
    4. More
    5. Reference documents
1. What is CRLF and LF

CRLF is the abbreviation of carriagereturnlinefeed. It means the carriage return to a newline.

LF is the line feed abbreviation, Chinese meaning is to wrap.

2, why to explore CRLF and LF

When you learn git software and install git to configuring the lien ending conversion, there are three options.

A. Checkout windows-style,commit Unix-style line endings.

B.checkout as-is,commit Unix-style Line endings.

C.checkout as-is,commit as-is Line endings.

This refers to the three operations (Windows-style,unix-style,as-is) that do two operations (CHECKOUT,COMMIT) that handle line endings.

Why do you get these three kinds of processing line endings (end Terminator)? A good explanation is given in the GIT help page.

Reference from:https://help.github.com/articles/dealing-with-line-endings

If you're using Git to collaborate with others on GitHub, ensure this Git isproperly configured to handle line endings.

Every time you press RETURN to your keyboard you ' re actuallyinserting an invisible character called a line ending . Historically, differentoperating Systems has handled line endings differently.

When you view the changes in a file, the Git handles line endings in the its own. Since you ' re collaborating on projects with Git and GitHub, Git mightproduce Unexpected results if, for example, you ' re wo Rking on a Windows Machine,and your collaborator have made a change in OS x.

The meaning is well understood, it is not translated. Due to historical reasons, various operating systems have taken different approaches in processing end-of-line terminators. While Git and GitHub

3, three ways to deal with the difference

Crlf->windows-style

Lf->unix Style

Cr->mac Style

Crlf means ending with a carriage return of two characters (that is, we often use "\ r \ n" line wrapping in Windows programming)

LF represents the end of a sentence, only line breaks are used.

Cr indicates that only carriage returns are used.

4. How to convert in git?

In git, configure it with the following command

$git config--true# Configure git on Windows to properly handle line endings 

Explanation: CORE.AUTOCRLF is a variable in git that handles line endings and can be set to three values--true,inout,false.

What is the effect of setting three values?

If core.autocrlf is set to true, that means this any time you add a file to the git repo that git thinks is a text file, it'll t Urn all CRLF line endings to just LF before it stores it in the commit.

Set to True, Git treats the file as a text file when it is added to the Git repository. He will turn the CRLF into LF. "2"

If core.autocrlf is set to False, no line-ending conversion was ever performed, so text files was checked in As-is. This usually works OK. "2"

When set to False, Line-endings will not do the conversion operation. The text file stays the way it was.

When set to input, add file git repository stone, git put CRLF programming lf. When someone check the code or the LF mode. Therefore, do not use this setting under the Windows operating system.

This is the explanation given in reference 2 that I hope can help everyone.

Yet another A-show how autocrlf works

1) true:             x -> LF -> CRLF2) input:            x -> LF -> LF3) false: x -> x -> x

where x is either CRLF (Windows-style) or LF (Unix-style) and arrows stand for

checked out file
More:

More complex configuration commands See website: https://www.kernel.org/pub/software/scm/git/docs/git-config.html

For LF and CRLF discussion see: HTTP://STACKOVERFLOW.COM/QUESTIONS/1967370/GIT-REPLACING-LF-WITH-CRLF

You can also provide a special --global flag, which makes Git usethe same settings for line endings across every Loc Al Git repository on your computer.

Reference documents

"1" https://help.github.com/articles/dealing-with-line-endings

"2" Http://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf

gexiaochuan122 posted on 2014-4-22 16:43:38 original link

CRLF and LF

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.