CRLF and LF

Source: Internet
Author: User
Tags using git

Clip:

    1. What is CRLF and LF
    2. Why explore CRLF and LF
    3. Three different ways of handling
    4. Many other
    5. References
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 very 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 press on return your keyboard you ' re actuallyinserting an invisible character called a lineending. 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 very good to understand, 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 indicates the end of the sentence. Just use line breaks.

Cr indicates that only carriage returns are used.

4. How to convert in git?

In git, configure with the following command

$git config--global core.autocrlf true # Configure Git on Windows to properly handle line endings
Explanation: CORE.AUTOCRLF is a variable in git that handles line endings. Ability to set three value--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. So under the window operating system. Do not use this setting.

This is a reference to the interpretation of article 2 to be able to 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

file to commit -> repository -> checked out file
many others:

More complex configuration commands See site: 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 acrossevery local Git repository on your computer.

References

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

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


Copyright notice: This article Bo Master original article, reproduced please contact Bo Master, blog, without consent may not be reproduced.

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.