Disable git EOL Conversions

前端 未结 5 1102
醉梦人生
醉梦人生 2020-12-07 11:47

I am trying to get git to not change any line endings whatsoever for any operation. Unfortunately, it seems to do so not matter what. I have reduced it down to the followi

5条回答
  •  粉色の甜心
    2020-12-07 11:56

    Inside your project, there should be a .gitattributes file. Most of the time, it should look like below (or this screen-shot):

    # Handle line endings automatically for files detected as text 
    # and leave all files detected as binary untouched.
    * text=auto
    
    # Never modify line endings of our bash scripts
    *.sh -crlf
    
    #
    # The above will handle all files NOT found below
    #
    # These files are text and should be normalized (Convert crlf => lf)
    *.css           text
    *.html          text
    *.java          text
    *.js            text
    *.json          text
    *.properties    text
    *.txt           text
    *.xml           text
    
    # These files are binary and should be left untouched
    # (binary is macro for -text -diff)
    *.class         binary
    *.jar           binary
    *.gif           binary
    *.jpg           binary
    *.png           binary
    

    Change * text=auto to * text=false to disable automatic handling (see screen-shot).

    Like this:

    If your project doesn't have a .gitattributes file, then the line endings are set by your git configurations. To change your git configurations, do this:

    Go to the config file in this directory:

    1) C:\ProgramData\Git\config

    2) Open up the config file in Notepad++ (or whatever text editor you prefer)

    3) Change "autocrlf=" to false.

提交回复
热议问题