Change casing of file or directory in Git - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

Change casing of file or directory in Git
=========================================

### [\#Git](https://rocketeersapp.com/knowledge/git)

Renaming already commited files or directories only for casing in Git will be ignored and will not show up as a change you can commit.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on November 29, 2022 · 1 minute read

1. [The problem](#content-the-problem)
2. [The reason](#content-the-reason)
3. [The fix (without changing the config)](#content-the-fix-without-changing-the-config)

[\#](#content-the-problem "Permalink")The problem
-------------------------------------------------

Sometimes you encouter the problem that a file or directory does not have the correct case-sensitive name it should have. So you rename the file and change its casing. After this change, Git does not show this and the renaming can't be commited.

So this is not enough:

`mv File.php file.php`

[\#](#content-the-reason "Permalink")The reason
-----------------------------------------------

Since Git version 1.5.6 there is a setting `core.ignorecase` that defines if casing should be ignored by default or not. To change the default setting to pick up casing changes, you can run inside the project:

 ```
git config core.ignorecase false

```

Or to disable it completely on your computer, you can set it globally using:

 ```
git config --global core.ignorecase false

```

[\#](#content-the-fix-without-changing-the-config "Permalink")The fix (without changing the config)
---------------------------------------------------------------------------------------------------

To fix this issue without changing any Git configurations: after you execute the `mv` command line from before, you also need to tell git that the filename has changed. This can be done by using:

 ```
git mv --cached File.php file.php

```

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Git](https://rocketeersapp.com/knowledge/git)

- [Removing tracked files in Git that should have been ignored](https://rocketeersapp.com/knowledge/removing-tracked-files-git)
- [Git fatal: refusing to merge unrelated histories](https://rocketeersapp.com/knowledge/git-refusing-to-merge-unrelated-histories)
- [GitHub Permission denied (publickey)](https://rocketeersapp.com/knowledge/github-permission-denied-publickey)
- [Git fatal: not a git repository](https://rocketeersapp.com/knowledge/git-not-a-git-repository)
- [Git: Updates were rejected (non-fast-forward)](https://rocketeersapp.com/knowledge/git-updates-were-rejected-non-fast-forward)
