1

I changed the name of a file to start with a lowercase letter instead of an uppercase letter, because auto-refresh wasn't working in development for files starting with capital letters, for whatever reason. I messed around with the config to make git case sensitive (or the opposite; can't quite remember). Now my project is how I want it to be on the local repo. The folder structure (the relevant parts) on the local repo looks like this:

Components/
-- home-page/
-- burger.js
-- footer.js
-- layout.js
-- navbar.js
-- navlink.js

In the remote repo, it looks like this after pushing this project to it:

Components/
-- Layout.js
-- Navbar.js
-- burger.js
-- footer.js
-- layout.js
-- navbar.js
-- navlink.js

As you can see, Layout and Navbar appear to be duplicated, where one file is capitalized, and the other isn't. I don't quite understand why the capitalized files are pushed to the remote repo when they aren't present in the local repo. I suspect it has something to do with me setting the config variable for 'ignorecase' to be false at some point.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
AlePouroullis
  • 333
  • 2
  • 12

1 Answers1

2

This looks like a case sensitivity issue : you are looking as the list of files on disk in your local clone (which, I assume, is on a Windows or MacOS system), and compare it to the view of what is stored in your repository, through the GUI of your central server (github or gitlab ? or perhaps Azure Devops ?).


To inspect, on your local system, the content of what is stored in your git repo : you can use git built in commands, such as git ls-files or git ls-tree :

git ls-files # will list all files in your repo

git ls-tree --name-only HEAD: # will list files at the root of your repo
git ls-tree --name-only HEAD:Components/

If you know that one version of a file is "not the good one", and that the fix is simply to remove it, you can use git rm --cached (which is case sensitive) :

# from what I understood: you want to get rid of the "uppercased" files
git rm --cached Navbar.js Layout.js
git commit

To avoid future issues : you probably want to set

git config core.ignorecase true

See a nice explanation in this SO answer

LeGEC
  • 46,477
  • 5
  • 57
  • 104
  • Yes, you've got it right: I'm comparing the files on disk to those stored on the remote repo which I see on the github website. – AlePouroullis Jul 19 '22 at 14:05
  • You could also check the output of `git ls-tree -r HEAD` and you should see the list as in the remote. – eftshift0 Jul 19 '22 at 14:21
  • 1
    Except for weird special case one-off temporary things, you generally *should not* set `core.ignorecase` one way or the other. Git uses it to *predict what the file system will do* and if the file system behaves in the other way, bad things may happen (the one-off tricks exist because sometimes good things happen instead). – torek Jul 19 '22 at 18:32
  • 1
    Git will set `core.ignorecase` based on how the file system actually behaves, at the time you create the file system. So if you've moved a repository *to* a *different* file system, that's the one time you might want to change `core.ignorecase` other than for the one-off tricks. – torek Jul 19 '22 at 18:32
  • Thanks for all the responses, everyone. I now better understand where I was going wrong. Also some handy extra things you introduced to me, like listing the files in the remote repo via terminal. Appreciate it! – AlePouroullis Jul 19 '22 at 18:53