Git/Windows - Case sensitivity issues when checking out a branch (and pulling/merging a branch). Affected files are all lowercase in Windows Explorer

988 views Asked by At

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

4

There are 4 answers

0
Randy Leberknight On

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.

0
CherryDT On

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

2
di0 On

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
0
user2987828 On

It is possible to work on windows, without administrative rights, by cloning the git project, then using in MobaXterm (or your prefered shell):

mkdir caseSensitiveSubTree
fsutil.exe file setCaseSensitiveInfo caseSensitiveSubTree
cd caseSensitiveSubTree
git clone ssh://git@gitlab/inserGitAccount/myProject.git
mv myProject ..
cd ..
rmdir caseSensitiveSubTree
cd myProject

Then you can work, and git is in a case insensitive folder. I tested it on windows 10.