'Git/Windows - Case sensitivity issues when checking out a branch (and pulling/merging a branch). Affected files are all lowercase in Windows Explorer
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
Solution 1:[1]
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.
Solution 2:[2]
Enable case sensitivity on the folder in Windows. (NTFS has this feature since April 2018.)
fsutil file setCaseSensitiveInfo <folder> enable
See https://docs.microsoft.com/en-us/windows/wsl/case-sensitivity
Solution 3:[3]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Randy Leberknight |
Solution 2 | CherryDT |
Solution 3 | di0 |