Git when used with Mac and Windows simultaneously gives unnecessary conflicts

喜夏-厌秋 提交于 2019-12-06 15:37:13

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.

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 ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!