Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Working in git with directories with the same name but different case in Windows

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

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

like image 317
Elmo Avatar asked Jan 02 '15 22:01

Elmo


1 Answers

Short answer: You can’t do this easily.

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.

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.

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.

like image 110
poke Avatar answered Oct 31 '22 01:10

poke