Background
If you use git from the command line as I do, you will likely run into git file command requests that does not stick.
For instance, you issue “git add <filename>“.
And, issue “git commit” or “git status” and notice that the file you added is not tagged for local commit.
If your file name is correct, you may have experience the issue highlighted in this post.
Troubleshoot
Outline
- OS Commands
- File List
- Microsoft Windows
- dir
- Linux
- ls
- Microsoft Windows
- File List
- Git
- Git Command
- git status
- Git Configuration
- File
- File – .git\config
- [core] / ignorecase = true
- File – .git\config
- Git Command
- git config
- local
- global
- git config
- File
- Git Command
OS Commands
File List
OS – Microsoft Windows
dir
On a machine running Microsoft Windows, please try using the “dir” command.
OS – Linux
ls
On a machine running Linux, please try using the “ls” command.
Summary
Irrespective of the OS that you using, your hope is to compare the file names.
The name should be same as the one you use targeted within the git command; making sure to match on case, as well.
Git
Git Command
Git Status
Please try using git status to get a file level read of your repository.
My go to command git status option is the “-u” option.
In essence, I issue “git status -u“.
Git Configuration
File
File – .git\config
[core] / ignorecase = true
Sample – Linux
cat .git/config
Sample – Windows
type .git\config
Output – Image
Output – Text
[core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true ignorecase = true
Explanation
- ignorecase
- Setting:- ignorecase = true
- Ignore case is set to true
- Which seems to imply that case sensitivity is set to be immaterial when it comes to file names
- Setting:- ignorecase = true
Git Command
git config
local
core.ignorecase
get
git config --local core.ignorecase
Output – Image
Output – Text
>git config --local core.ignorecase true
Explanation
- ignorecase
- Setting:- ignorecase = true
global
core.ignorecase
get
git config --global core.ignorecase
Output – Image
Output – Text
git config --global core.ignorecase
Explanation
- ignorecase
- Setting:- ignorecase = <blank>
- In our case, the ignorecase option was not set globally
Additional Reading
- Scott Hanselman
- Git is case-sensitive and your filesystem may not be – Weird folder merging on Windows
Link
- Git is case-sensitive and your filesystem may not be – Weird folder merging on Windows
- syntevo
- SMARTGIT
- Be sure that core.ignoreCase matches your OS!
Link
- Be sure that core.ignoreCase matches your OS!
- SMARTGIT
Scott Hanselman
Git is case-sensitive and your filesystem may not be – Weird folder merging on Windows
Folders with mismatched names Worked on MS Windows and Mac OS.
But, failed on Linux.
Premise is that on MS Windows and Mac OS, we have a single folder.
On Linux, two or more different folders; for each case-sensitive folder name.
Syntevo GmbH
SmartGit
Be sure that core.ignoreCase matches your OS!
Marc @ Ainring, Germany based Syntevo GmbH was just as circumspect.
$ git config --unset core.ignoreCase
As Git’s internal default is false, there is nothing more to do on Linux/MacOS. On Windows, you have to add core.ignoreCase=true as global default:
$ git config --global core.ignoreCase true
Summary
For the sake of this particular post, I intentionally circumvented an attempt to add a new file to Git, knowing that it will not be added; as I mangled via casing the file name.
If you google on the error, and someone says check on the core.ignorecase setting, please do check on it.
But, please carefully consider prior to amending globally or locally to a targeted repository.
[…] learningintheopen.org/2023/02/15/git-file-operations-case-sensitivity/ […]