2

I have a git repo and I generally work on it via my mac laptop. I had also cloned the repo on my windows laptop (using git bash and cygwin) earlier, everything was fine, but today when I took a git pull I got several merge conflicts though I had no local changes in my windows laptop.

I think it may be that the folders in mac use / (forward slash) and in windows \ (backward slash) but I am not sure.

Can anyone tell me why this happened and how to resolve this?

Ram Patra
  • 16,266
  • 13
  • 66
  • 81

2 Answers2

9

When working on the same repository from different operating systems you should define appropriate line endings on the repository level, or if you are the only user, configure your Git clients to do line ending conversions where needed. Examples here (Github) and here (official Git documentation).

What you most likely should do is configure CR+LF checkouts on windows

git config --global core.autocrlf true

and force LF on commit for Mac.

git config --global core.autocrlf input

Dealing with the whitespace differences on every merge is going to become annoying and cumbersome very fast.

sendaran
  • 566
  • 3
  • 9
3

Folder separator in the pathes can't do that, git is enough smart in this sense.

The whitespaces differ:

  • Mac uses different endline (0x0d instead of 0x0d 0x0a in windows)
  • Tabs may also differ, depending on the text editor setup (tab is \t on machine1 while it is 4-8 spaces on machine2)

The solution for this is the --ignore-all-space flag, so:

git merge --ignore-all-space ...
peterh
  • 11,875
  • 18
  • 85
  • 108