Updating the Git index failed, LF will be replaced by CRLF?

前端 未结 4 1220
别跟我提以往
别跟我提以往 2021-02-15 17:19

I\'m using git-gui for version control and pushing them to remote locations. When I tried to Rescan files for changes, I got this message and I\'m not sure what that means. Plea

4条回答
  •  执笔经年
    2021-02-15 17:59

    I faced similar issues and decided to have a closer look to my configuration.

    New Line Characters on Windows / Linux / MAC:

    1. MAC OS before X: \r = CR (Carriage Return)
    2. MAC OS X / UNIX: \n = LF (Line Feed)
    3. Windows: \r\n = CR + LF

    Don't panic. Git can handle the conversion between platforms for you.

    Git should store the line ending as LF in the repo.

    Set it to;

    TRUE - If you are on Windows:

    git config --global core.autocrlf true
    

    This converts LF endings into CRLF when you check out code.

    INPUT - If you are on a MAC/LINUX:

    You don't need to convert anything, Git uses LF and your MAC uses LF.

    But, you can tell git to convert any CRLF if one pass through:

    git config --global core.autocrlf input
    

    False - Not recommened

    I don't recommend this, but just for the sake of this explanation:

    If you are a windows dev only working on windows machine and you are 100% sure you will never work with people on MAC:

    git config --global core.autocrlf false
    

    UPDATE:

    As commented below, I didn't mention the .gitattributes where one can default these settings for a project.

    If you havetime, here is the doc: http://git-scm.com/docs/gitattributes

提交回复
热议问题