0

Having a really strange issue with git and Windows regarding case sensitivity.

I am not a master at git but I'm also not a beginner. Just want to throw that out there.

Problem I am facing:

  • Clone a repository (don't specify branch, just grab what's on remote origin master)

  • Checkout an existing dev branch (let's call it DEV)

  • A number of files are now all lowercase

    a. Both branches have the same casing for these files

    b. The affected files seem to be the ones that contain content differences between the two branches

    c. Not all files are affected

Additional notes:

  • Using a Windows system (which is case-insensitive)

  • git config file defines ignorecase = true

    a. Tried switching to false, did not eliminate this issue

  • Tried running ls-tree on each branch, both show the files as having the same case (not all lowercase)

  • When switching to Dev branch and back to master, the affected filenames remain lowercase

  • Cloning the Dev branch directly works fine. Does not result in these lowercase filenames

I've tried a number of things to solve this problem, albeit no solution as of yet.

Does anybody have any clue what may be going on here? I'm not finding much support regarding this issue.

This question looks to be related (but has no answer):

Switching GIT Branches randomly changes filename case

Thanks

JayLee21
  • 13
  • 3
  • Find yourself a Linux system. That's really the right way to handle this problem; everything else is too painful for words. (Consider setting up a Linux VM on your Windows system: I have one on my mac for similar reasons.) – torek Oct 26 '21 at 20:58
  • Is this causing a practical problem? As far as I know, Windows is not case sensitive, so as long as Git is working properly, there shouldn't be a functional problem for software on your system. – bk2204 Oct 26 '21 at 21:20
  • @ torek we are required to use Windows systems unfortunately. @ bk2204 You are correct. git is working properly as it detects the proper casing for every file. The practicality part of this has to do with the fact that this is Matlab code we are talking about and Matlab is case sensitive :/ ADDITIONAL IMPORTANT INFO: This only happens when the local repository is on the network drive. This does not happen when the repository is on the local hard drive – JayLee21 Oct 27 '21 at 17:34

3 Answers3

0

There may be someone who can figure out exactly what is happening and why, however I'm afraid most the the experience folks who answer this will offer something along the lines of "if it hurts, don't do it".

Case in point, torek suggested getting a Linux system in a comment. Torek is one of the most experienced folks on stackoverflow and if they don't have an answer for you the odds are that it is not coming.

If you don't want to get a Linux system, another option is to change the case on all files to be the same (e.g. all lower case).

People often advise folks to not mix the case in filenames for this reason. I personally prefer all lower case.

Randy Leberknight
  • 1,363
  • 9
  • 17
0

Enable case sensitivity on the folder in Windows. (NTFS has this feature since April 2018.)

fsutil file setCaseSensitiveInfo <folder> enable

See https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity

CherryDT
  • 25,571
  • 5
  • 49
  • 74
0

Locate Windows Case-Insensitive Duplicate Directory Paths in git repo

open Powershell as Administrator

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

(restart machine required)

open Powershell as Administrator

cd drive:\your\root\folder

(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable}

open git Bash

cd /drive/your/root/folder

find * -type d | uniq -di
di0
  • 1
  • You don't need to recurse for setCaseSensitiveInfo, it is inherited from the parent directory, so you only need to set it on the root dir. But it won't work anyway, because the directory needs to be empty to enable case sensitivity... – Thomas Levesque Jun 07 '22 at 09:57