2

Possible Duplicate:
What's the best CRLF handling strategy with git?

I'm currently working on a project where almost every time I merge master into my branch, I get merge conflicts where git says the entire file has changed. Often when I compare these files using Notepad++'s compare tool, it reports that only a couple of lines have actually changed and often it shouldn't even result in a conflict.

For a while I've simply put up with this behaviour as a problem that has to be suffered whilst working cross-platform (our team uses a mixture of windows 7, OSX and debian for development), but today when I merged there were some serious issues which are stopping me from moving forward. I've looked into this myself and it seems that it might be related to the git core.autocrlf config, but I'm unsure how to solve this issue so that either it goes away immediately, or will slowly disappear as git fixes the damage I've previously done. Could anyone give any suggestions as to how to fix this?

Thanks,
Alex

Community
  • 1
  • 1
Alex Jeffrey
  • 523
  • 6
  • 17
  • 3
    possible duplicate of [What's the best CRLF handling strategy with git?](http://stackoverflow.com/questions/170961/whats-the-best-crlf-handling-strategy-with-git), or possibly [Why should I use core.autocrlf=true in git?](http://stackoverflow.com/questions/2825428/why-should-i-use-core-autocrlf-true-in-git) – Romain Aug 14 '12 at 14:51
  • the thing is I'm unsure whether the issue is CRLF-related, this is just a possibility I've found through googling and I'm no git expert – Alex Jeffrey Aug 14 '12 at 14:51
  • Can you refine the diffs to see if the changes are at the newlines? If so, it's probably a `CRLF` problem (especially since you're using multiple platforms). – Noufal Ibrahim Aug 14 '12 at 14:52
  • I suspect it is CRLF related because lines that have no indentation or trailing whitespace and are otherwise identical are marked as conflicting. – Alex Jeffrey Aug 14 '12 at 14:52
  • Check also your gitattributes files: http://stackoverflow.com/questions/2333424/distributing-git-configuration-with-the-code/2354278#2354278 core.eol directives can also affect crlf. – VonC Aug 14 '12 at 15:09

1 Answers1

6

I've finally resolved this problem - I had to enable autocrlf. I've read a lot of recommendations against this flag, but it appeared to work in this case.

git config --global core.autocrlf true

Alex Jeffrey
  • 523
  • 6
  • 17
  • 6
    As an answer to this question, shouldn't you also post how you did it? – Dagrooms Jul 14 '15 at 13:10
  • 1
    I am having the same problem, but this doesn't work. Trying to push and pull back and forth from windows and unix ubuntu. Do I just need to set that option on both machines and then pull? Or do I need to re-save all of the files and recommit before doing so? – Paul Apr 13 '17 at 17:34
  • unfortunately it's been a while since I've had to do this (my new work is all-Mac/Linux) but I believe there's other related settings that can help - core.eol, something like that? Sorry I can't be of much more help. – Alex Jeffrey Apr 15 '17 at 13:16
  • @Dagrooms `git config --global core.autocrlf true` – Alex Jeffrey Apr 15 '17 at 13:17
  • @AlexJeffrey wow man - I posted this back in the days of my internship. Thanks for finally getting back to it - but you should probably edit the original post. – Dagrooms Apr 17 '17 at 14:08
  • yeah I haven't logged into my stack account in literally years haha – Alex Jeffrey Apr 17 '17 at 15:04