Christina Ellul
Christina Ellul

Reputation: 73

Case sensitivity with file names in VS Code and Windows Git

I'm having an issue with VS Code v1.26.1 on Windows 10. I cloned a repository where, in the same directory, it has file names with the same name but different cases for example: filename.ext and FileName.ext.

VS Code thinks that these are the same file with a change, therefore it is showing them in the Source Control, but when I discard the changes it just changes the names back to the other case + it won't stash or stage them.

I have tried the git config core.ignorecase false and git config --global core.ignorecase false commands but it doesn't seem to do anything. I also tried changing it to true and back to false.

Anyone had/having this issue and found a work around for this?

PS: I cannot change the file names to something else. These file names MUST stay the same.

Upvotes: 7

Views: 14859

Answers (3)

Naresh Nagpal
Naresh Nagpal

Reputation: 387

The 2 steps rename works fine for me.

git mv OriginalFolder tempfolder
git mv tempfolder originalfolder
git commit -m "renamed folder to lowercase"

Upvotes: 2

It'sNotMe
It'sNotMe

Reputation: 1260

Late answer, but Git and Case Sensitivity solved the problem for me.

My project wouldn't compile because it was looking for app.js instead of the file's actual name App.js. I renamed the file in VSCode and the project compiled. However, after every commit, App.js reverted to app.js.

To force git to detect the change I used git-mv.

git mv app App

According to the post author:

The tracked file or folder you want to recapitalize has to be explicitly renamed using a Git command. git mv works the same as mv, except it informs Git that a file or folder has been renamed by immediately staging the change.

Upvotes: 2

Alex Cohn
Alex Cohn

Reputation: 57183

in April 2018, NTFS became fully case-sensitive (on demand).

Before checking out your project, run this in elevated command prompt:

fsutil.exe file SetCaseSensitiveInfo git_project_root enable

It seems, though, that Visual Studio must be fixed to work with such folders correctly. I have not tried Visual Studio Code on these.

Upvotes: 1

Related Questions