Home > front end >  Identical files, one capitalized and the other not, appearing in remote repo, but not local repo
Identical files, one capitalized and the other not, appearing in remote repo, but not local repo

Time:07-20

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.

CodePudding user response:

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

  • Related