Over a million developers have joined DZone.

Git and The Hell of Case Sensitivity

DZone 's Guide to

Git and The Hell of Case Sensitivity

CASING is ImPoRtAnT. Especially in git, where using the incorrect casing could become a real source of irritation to developers.

· Open Source Zone ·
Free Resource

If you know how git works, you are perfectly aware that, even if you work in operating systems with a case insensitive file system, all commits are case sensitive. Sometimes if you change the case of a folder, then commit modifications of files inside that folder, you will run into problems because if the casing of the path changes, the files are different for the Git Engine (but not for operating systems like Windows).

In the long run, you will face some annoying problems, like git showing that some of the files are modified (while you didn’t touch them) and being unable to undo changes or work with those files. This problem will become really annoying during rebase operations.

Having files with only case differences is one of the most annoying problem with Git Repositories in Windows.

Luckily enough, Azure DevOps has an option for Git Repository where you can have the engine prevent commits that contains file names with only case differences, to avoid this problem entirely.


Figure 1: Options for cross-platform compatibility can solve most headaches

The first option completely blocks pushes that contains files not compatible across platforms and is the option that we are looking for because it will block you from pushing code that will lead to case sensitiveness problems.

The other two options are equally necessary because the second one will prevent you from pushing a path with forbidden names or incompatible characters (remember that this is different between Windows and Linux). Finally, the third one will block pushes that contains a path with unsupported length, a problem that is really nasty for Windows Users.

In the end, if you have a case sensitivity problem in your repository and you already pushed your code, because you did not have these options enabled, I can suggest you try a nice tool available in GitHub that finds all problems in the repository and fixes them called Git Unite. You can clone the project, compile it in Visual Studio, then just launch from command line giving the path of a local git repository as single arguments and it will do everything automatically.

git ,open source ,solutions ,tools ,windows ,git repository ,git unite ,casing

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}