Git 中区分大小写

发布于 2024-12-27 16:50:01 字数 248 浏览 1 评论 0原文

我在使用 git 时遇到了问题。基本上我设置为 false core.ignorecase 因为我想更改某些文件夹名称的大小写(因为我在 OSX 下使用不区分大小写的文件系统,所以更改不会以其他方式显示) 。当我提取数据时,我注意到现在每个重命名的文件夹在存储库中都会出现两次,同时具有旧名称和新名称。我不知道如何删除旧文件夹,因为它们没有出现在本地(我尝试再次将 core.ignorecase 设置为 true,但没有帮助)。

I've run into a problem with git. Basically I set to false core.ignorecase because I wanted to change the case of the names of some folders (since I'm under OSX with a case-insensitive filesystem, the changes weren't shown otherwise). When I pulled my data, I've noticed that now every renamed folder appears twice on the repository, with both the old and the new name. I don't know what to do to remove the old folders since they don't appear locally (I've try to set core.ignorecase to true again but it isn't helping).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

○闲身 2025-01-03 16:50:01

可能是类似于msysgit问题中的此评论 (对于另一个不区分大小写的操作系统:Windows)可以提供帮助吗?

我也遇到过同样的问题。在 Eclipse 中重构了包名称,并由于文件夹名称未恢复而切换到以前的版本。我使用的是 Windows 7,Git 1.7.0.2.msysgit.0

我的文件夹在 Windows 中被重命名为“folder”,但在 Git 中显示为“Folder”。
我通过在 Windows 中将其重命名为“Folder”然后运行来修复了该问题:

git mv "Folder" "Folder2"
git mv "Folder2" "folder"

请注意,自 git 2.0.1(2014 年 6 月)以来,git mv 文件夹文件夹应该可以工作!

请参阅“Git:更改文件名的大小写

May be a workaround similar to this comment in an msysgit issue (for another case-insensitive OS: Windows) could help?

I've encountered this same issue. Refactored a package name in Eclipse and switching to a previous build broke due to the folder name not reverting. I'm using Windows 7, Git 1.7.0.2.msysgit.0

My folder was renamed in Windows to "folder" but was displayed as "Folder" in Git.
I fixed the issue by renaming it to "Folder" in Windows and then running:

git mv "Folder" "Folder2"
git mv "Folder2" "folder"

Note that since git 2.0.1 (June 2014), git mv Folder folder should just work!

See "Git: Changing capitalization of filenames"

送你一个梦 2025-01-03 16:50:01

在 macOS 上使用以下命令。这会将您的 git 配置更改为文件名区分大小写。

git config core.ignorecase false

您可以通过编辑 ~/.gitconfig 并在 core 下设置它来全局设置它,例如:

[core]
    ignoreCase = false

Use the following command on macOS. This will change your git configuration to be case sensitive on filenames.

git config core.ignorecase false

You can set this globally by editing ~/.gitconfig and setting it under core such as:

[core]
    ignoreCase = false
深海夜未眠 2025-01-03 16:50:01

您可以使用区分大小写的文件系统创建磁盘映像(最好是稀疏磁盘映像)并在那里签出您的 git 存储库。

下面的磁盘工具屏幕截图显示了如何创建区分大小写的磁盘映像。

磁盘工具设置

You can create a disk image (preferably a sparsebundle disk image) with a case-sensitive file system and checkout your git repository there.

The Disk Utility screenshot below shows how to create a case-sensitive disk image.

Disk Utility Settings

苍暮颜 2025-01-03 16:50:01

Mac OS X 默认情况下是“不区分大小写但保留大小写”。这是一个重要的区别。

我建议您创建另一个磁盘映像,并将其专门格式化为“HFS 区分大小写”。

Mac OS X by default is "case insensitive but case preserving". This is an important distinction.

I suggest you create another disk image, and specifically format it as "HFS Case Sensitive".

单挑你×的.吻 2025-01-03 16:50:01
git mv "Folder" "Folder2"
git mv "Folder2" "folder"
git commit -a -m "my message"
git mv "Folder" "Folder2"
git mv "Folder2" "folder"
git commit -a -m "my message"
黎歌 2025-01-03 16:50:01

最近在 [email protected] 上有一个关于区分大小写问题的较长帖子标题为 错误? Git checkout 失败并显示错误消息,该消息突出显示了不同平台之间区分大小写的问题以及要尝试的操作。

There is a longish recent thread on case sensitivity issues on the [email protected] discussion forum titled Bug? Git checkout fails with a wrong error message which highlights the issues, and things to try, of case sensitivity between different platforms.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文