Git当与Mac和Windows同时使用时会产生不必要的冲突 [英] Git when used with Mac and Windows simultaneously gives unnecessary conflicts
问题描述
我有一个git repo和我一般工作,通过我的Mac笔记本电脑。我还克隆了我的Windows笔记本电脑上的repo(使用 git bash
和 cygwin
),一切都很好,但今天我拿了一个 git pull
我有几个合并冲突
虽然我没有本地更改我的Windows笔记本电脑。 / p>
我认为可能是mac中的文件夹使用 /
(正斜杠)和窗口<$ c $
任何人都可以告诉我为什么会发生这种情况,以及如何解决这个问题?
/ p>当从不同的操作系统在同一存储库上工作时,应该在存储库级别定义适当的行结束,只有用户,配置您的Git客户端在需要时执行行结束转换。示例 here(Github)和 here(官方Git文档)。
您最可能应该做的是在Windows上配置CR + LF检查
git config --global core.autocrlf true
并强制LF提交为Mac。
git config --global core.autocrlf input
每个合并的空格差异将变得恼人和麻烦非常快。
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?
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.
这篇关于Git当与Mac和Windows同时使用时会产生不必要的冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!