• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Computing / Git Case Sensitive Rename

Git Case Sensitive Rename

Last updated on December 17, 2014 by Sal Ferrarello

One can rename a file with git mv however, if you try to use this technique to change the case of the filename it will fail and you’ll get fatal: destination exists. I prefer to keep all my filenames lowercase, so getting this to work is important to me.

If I modified the filename case from the OS but not through git, git would fail to detect the change.

How to Change the Case of a Filename within Git

As with any filename change, we want to do this as a separate commit.

To insure git detects the change, we’re going to change to a temporary filename and then back to our desired filename with the case change.

git mv FileName.txt filename.tmp
git mv filename.tmp filename.txt
git add filename.txt
gc -m 'case change of filename'

Photo from Little Visuals

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Computing Tagged With: command line, Git

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in