Learn why and how to use git mv instead of mv on MacOS when changes case on filenames.
One of my favorite things is to find an example of code that "Works on my machine" but fails in CI.
components/Form.js. I needed to import the new component into
Post.js. For my import, I added the following line to my imports:
import Form from "./components/form";
Once I had an import, I used the component, checked it locally with
localhost and verified everything looked good.
When everything was ready, I opened a PR and pushed with git, went to get some coffee, came back to merge amd saw a little. red. x.
Those little red X's can be surprising, especially when you didn't change much and the code you did change worked locally. I checked my Netlify build logs and found this:
If you're not used to seeing this (I've seen this before a few times when I was working on CI at WalmartLabs, enough so that it inspired me to write about the various types of case in programming), it's easy for your very first thought to be 'That file is definitely there...something must be wrong with the build process or build server."
While working on some react components, I decided to downcase all the filenames.
When I did a
git status I saw that everything was up to date even though I had clearly renamed the files.
This is a problem with HFS+ (the filesystem that most MacOS machines are formatted to by default).
The easiest way to always do this right in the future is to use
git mv <oldFilename> <newfilename>.
Hey, I'm Chase. I help aspiring entrepreneurs and makers turn their ideas into digital products and apps.
A figma community project of vectorized hand-drawn arrows.Go To Figma
A figma community project of vectorized hand-drawn lines.Go To Figma
A figma community project of vectorized hand-drawn shapes.Go To Figma
Subscribe to my Newsletter
Every other week I publish the Curiously Crafted newsletter.
In it, I explore the intersection of curiosity and craft: the people who make stuff, what they make and the way they pursue the craft of making.
I'm on almost all social media as @curiouslychase.