2

I am not completely sure if this issue has to do with Git or Unity's MonoDevelop text editor. For some reason, when I try to add my unity project files to the git repository it gives me an error saying: "warning: LF will be replaced by CRLF in .... The file will have its original line endings in your working directory."

I have looked at guides about this problem and have tried 'git config core.safecrlf false' yet I still get the problem.

The reason I am not sure if it is monodevelop or git causing the issue is because sometimes when I save my files it brings up a warning asking me to convert the line endings(ive never seen this before)

If anyone knows about this or can help me out that would be so helpful as I do not know where to look and this has really been bugging me.

Thanks

yoyo
  • 8,310
  • 4
  • 56
  • 50
Kyle Jensen
  • 419
  • 9
  • 27
  • This is not an error, but just a warning. Here is the answer you shold have found if you tried to: http://stackoverflow.com/questions/5834014/lf-will-be-replaced-by-crlf-in-git-what-is-that-and-is-it-important?rq=1 – ZuoLi Mar 14 '15 at 14:48
  • I would seriously consider using just about any IDE other than MonoDevelop. There are a great many issues with the IDE that just cause general inconveniences that can be easily avoided with the likes of VS such as your issue here. Also, to me it has always seemed incredibly slow compared to the likes of VS. – Benjamin James Drury Mar 15 '15 at 22:25
  • I agree, I prefer sublime for my other programming needs but MonoDevelop just came with Unity so Ive been using it. If I switch over to a different IDE how would it repair the files that are currently "broken" – Kyle Jensen Mar 16 '15 at 00:27

2 Answers2

1

On Windows I use autocrlf = true in my %USERPROFILE%\.gitconfig file:-

[core]
    autocrlf = true

However Unity's text serialisation means that all its asset types will always use linux line endings, so we need to tell git to leave those line endings alone.

I added to my .gitattributes file:-

# Declare unity data files that will always have LF line endings on checkout.
*.unity text eol=lf
*.asset text eol=lf
*.anim text eol=lf
*.lighting text eol=lf
*.renderTexture text eol=lf
*.wlt text eol=lf
*.controller text eol=lf
*.preset text eol=lf
*.overrideController text eol=lf
*.guiskin text eol=lf
*.mat text eol=lf
*.mask text eol=lf
*.spriteatlas text eol=lf
russ
  • 181
  • 1
  • 1
  • 10
0

Root cause

The line endings of your files would be following the windows convention which is CRLF and but the system you are currently working on follows other line ending format LF.

For further reading ... See here

cafebabe1991
  • 4,928
  • 2
  • 34
  • 42