我正在一个由混合 Linux/MacOS 开发人员组成的团队工作。MacOS 不区分大小写,而 Linux 区分大小写。我有以下问题:
我的(MacOS)机器:
$ git checkout master
$ echo hi > MyModule.js
$ git commit -a -m 'Create MyModule.js'
$ git push origin master
$ git checkout -b other-work
... (do work)
Run Code Online (Sandbox Code Playgroud)
同事的 (Linux) 机器
$ git checkout master
$ git pull
$ git mv MyModule.js myModule.js
$ git commit -m 'Rename MyModule.js to myModule.js'
$ git push
Run Code Online (Sandbox Code Playgroud)
我的 (MacOS) 机器
# Currently on branch other-work
$ git fetch
$ git checkout origin/master
error: The following untracked working tree files would be overwritten by checkout:
MyModule.js
# In order to resolve the issue, I have to resort to hackery:
$ rm MyModule.js
$ git checkout origin/master
$ git checkout -- myModule.js # Restore the rm'd file
Run Code Online (Sandbox Code Playgroud)
我真的很想避免所有这些黑客行为。我希望我的 MacOS git 知道文件名的大小写变化,以便我可以在分支之间自由切换。我已经尝试将ignorecase配置值设置为true 和 false 但这无济于事。
Jos*_*das 11
正如建议的,macOS 使用不区分大小写的文件系统。然而,这仅适用于默认卷。为了解决此问题,请在 macOS 计算机上创建另一个区分大小写的卷,并在其中存储共享代码。或者,在您的组织内进行标准化,这样区分大小写的文件就不再是问题。
要快速在 Mac 上创建卷,以便在等待内部标准讨论时不会被阻止,请访问“磁盘工具”并创建一个新的区分大小写的卷,例如:
这至少会让您移动,这样您的环境就会像您的同事一样,并且您所看到的错误应该不再发生。