How to make git ignore case

Before you start, you might want to copy the directory to somewhere safe in case of accidents.

First we'll check the current git configuration using the git config command:

git config --global --get core.ignorecase

To work case sensitive, which is what we want in this case:

git config --global core.ignorecase false

For this example, we will assume the directory we want to change, is already committed. To untrack a directory that has already been commited to your repository, stop tracking the directory. The directory will not be deleted:

git rm -r --cached <added_directory_to_undo>

Let's try this:

$ git rm -r --cached MyUpperCase
rm 'MyUpperCase/myfile2.txt'

To do the same with a file:

git rm --cached <added_file_to_undo>

Let's find out what happened:

On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        deleted:    MyUpperCase/myfile2.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)


Now we can move the file or directory:

mv MyUpperCase/ myuppercase/

Dry run add:

git add -n myuppercase

Add the changed directory:

git add myuppercase

The directory should be renamed:

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        renamed:    MyUpperCase/myfile2.txt -> myuppercase/myfile2.txt

Commit the changes:

$ git commit -am "Renamed the MyUpperCase/ directory"
[master 19b5e3a] Renamed the MyUpperCase/ directory
1 file changed, 0 insertions(+), 0 deletions(-)
rename {MyUpperCase => myuppercase}/myfile2.txt (100%)