git: merge conflicts over newline at end of file

后端 未结 1 1216
猫巷女王i
猫巷女王i 2021-01-28 15:34

I often get conflicts while pulling (merging) in git over differences in newlines at the end of the file.

The conflict comes out looking like this:

diff          


        
1条回答
  •  迷失自我
    2021-01-28 15:42

    These differences are resulting form the fact that different OS's have a different idea of what ends a line.

    Git usually handles those well, by defaulting the config value of core.eol to 'native'. However, if a developer does not have that setting for some reason, or committing UNIX-style files from Windows or vice versa, you might get these issues.

    It is best to find the source of the issue and deal with it there, otherwise, you can try to set different values for core.eol (lf/crlf), and see if it fixes that. If it only happens on a specific path, and not the whole project, you might be better off defining a gitattributes file for that path.

    0 讨论(0)
提交回复
热议问题