在git中使用Windows中具有相同名称但大小写不同的目录 [英] Working in git with directories with the same name but different case in Windows

查看:176
本文介绍了在git中使用Windows中具有相同名称但大小写不同的目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从Windows中的git repo中提取,该仓库有两个目录,分别为Foofoo.这两个文件夹具有不同的内容.

I want to pull from a git repo in Windows which has two directories, named Foo and foo. Both the folders have different contents.

由于Windows不区分大小写,并且不允许使用名称相同但大小写不同的文件夹,我该如何推送到git repo?

As Windows is case insensitive and doesn't allow folders with same name but different case, how do I push to the git repo?

推荐答案

简短的回答:您很难做到这一点.

Short answer: You can’t do this easily.

默认情况下,这是Windows子系统的限制.除非您使用较低级别的系统调用,否则Windows在不同大小写之间不能有所不同.因此,即使Git能够跟踪差异,也无法将这些差异传达给文件系统.

By default, this is a restriction of the Windows subsystem. Unless you use lower level system calls, Windows cannot differ between different casing; so even if Git is able to keep track of the differences, it can’t communicate these difference to the file system.

phuclv 在评论中指出, 可以重新配置Windows内核要区分大小写.在Windows 10中,这甚至对单个文件夹> ,因此您可以使用它在需要的地方添加兼容性.但是,每个文件夹的区分大小写不会继承,因此您需要为Git创建的文件夹手动更改此设置,这可能会有些麻烦,并且大多是一种解决方法.

As pointed out in the comments by phuclv, it is possible to reconfigure the Windows kernel to be case sensitive. In Windows 10, this even works for individual folders, so you could use this to add compatibility where you need it. However, the case sensitivity per folder is not inherited, so you will need to manually change this for the folders that Git creates which might be a bit bothersome and makes this mostly a workaround.

相反,您可以使整个文件区分大小写,但这可能会带来其他影响,因此请小心如果您想这样做.

Instead, you could make the whole file system case-sensitive but that might have additional implications, so just be careful if you want to do that.

还请注意,即使在较低级别支持区分大小写的内容,大多数Windows应用程序(包括内置Windows工具)也可能无法使用此功能.因此,这仅允许您使用某些工具处理这些文件.我的猜测是,例如,大多数基于GUI的Git工具在这里根本无法使用.

Also note that even if there is support for case-sensitive content on the lower level, most Windows applications, including built-in Windows tools, will probably not be able to work with this. So this will only allow you to work with these files from certain tools. My guess would for example that most GUI based Git tools simply won’t work here.

如果您不想进行这些修改,那么您可能还可以做的是创建部分提交,在其中您只需将文件添加到正确的文件夹即可(您需要在文件名之间进行重命名以获得不同的大小写).但这将是不切实际的.

If you don’t want to make these modifications, then what you maybe also could do is create partial commits where you just add files to the correct folder (you need to rename it in-between to get the different casing). But that will be very impractical.

我认为,最好的解决方案是简单地避免在名称冲突的文件夹上使用多个文件.即使在区分大小写的系统上,这也只会使事情更加混乱.通过完全避免这种情况,您还可以使所有其他开发人员更轻松地与项目进行交互.

In my opinion, the best solution is to simply avoid using multiple files on folders with conflicting names. Even on case-sensitive systems, this will only make things more confusing. By avoiding this completely, you also make it easier for all other developers to interact with the project.

这篇关于在git中使用Windows中具有相同名称但大小写不同的目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆