A TypeScript application I was working on compiled without any problems on my machine. However, in preparation to onboard new developers and test that the project would boot from scratch, I cloned the repo from GitHub to a new directory, and saw an error message similar to the following when attempting to build for the first time:

./src/pages/Shelter.tsx
Cannot find file: 'CatContainer.tsx' does not match corresponding name on disk: './src/components/cats/Cat'.

The issue was that I had renamed a folder to start with a lowercase letter instead of uppercase using VS Code, like changing ./src/components/Cats to ./src/components/cats. On my macOS machine, only the folder ./src/components/cats existed. However, on GitHub, both the lower and uppercase directories were there. The capitalized version of the directory held files I had created before changing the name on my machine, and the lowercase version of the directory held files I had created after changing the name on my machine. In the newly cloned project, only the uppercase version seemed to be there, containing all the files.

This happened because of differences in the treatment of casing between macOS and Linux. Apparently, Mac is case insensitive, but Linux is not, and git did not track the changes I made as expected.

I found a command to easily resolve this in the blog post How to do a case sensitive file rename in git on macOS by Sebastian De Deyne: git mv. I attemped to use the command to directly change the folder from uppercase to lowercase folder in the newly cloned project:

git mv src/components/Cats sr/components/cats

But I was met with the error:

fatal: renaming 'src/components/Cats' failed: Invalid argument

I found the blog post Rename folder to lowercase - Git by Prayatna Bhattarai, and followed the strategy of using a temperory directory.

git mv src/components/Cats src/components/cats-temp
git mv src/components/cats-temp src/components/cats

This worked. I was able to commit the changes and push from the newly cloned project, and get another newly cloned project to build and run.