Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git when used with Mac and Windows simultaneously gives unnecessary conflicts

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?

like image 682
Ram Patra Avatar asked Jan 18 '26 23:01

Ram Patra


1 Answers

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.

like image 129
sendaran Avatar answered Jan 20 '26 14:01

sendaran