[Git] Case-sensitive folder names and file names

[Git] Case-sensitive folder names and file names

2023-06-26 hit count image

Let's see how to set folder names and file names to be case-sensitive in Git.

Outline

When managing a project using Git, you may accidentally create a file name or folder name in lowercase or uppercase.

.
└── test_File.txt

0 directories, 1 file

In this case, modify the file name or folder name as follows.

.
└── test_file.txt

0 directories, 1 file

However, when you try to commit it, Git may not recognize this change when you check it with the git status command.

git status

On branch main
nothing to commit, working tree clean

In this blog post, I will introduce how to change Git settings to solve this problem that Git cannot distinguish between uppercase and lowercase letters.

ignorecase

Git provides a setting called ignorecase. This setting is used to set whether Git recognizes uppercase and lowercase letters when recognizing file names and folder names.

The ignorecase setting is set to false by default. Therefore, Git basically manages uppercase and lowercase letters separately. However, ignorecase is set to true when git clone or git init is executed sometimes.

If you have the problem that Git cannot distinguish between uppercase and lowercase letters like this, execute the following command to make Git distinguish between uppercase and lowercase letters.

git config core.ignorecase false

Then, check whether Git distinguishes between uppercase and lowercase letters by executing the following command.

git status

Unlike before, you can see that Git distinguishes between uppercase and lowercase letters as follows.

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

nothing added to commit but untracked files present (use "git add" to track)

Completed

Done! We’ve seen how to make Git distinguish between uppercase and lowercase letters. By default, ignorecase is false, so this problem does not occur, but if you have this problem, please refer to this blog to change the ignorecase setting.

Was my blog helpful? Please leave a comment at the bottom. it will be a great help to me!

App promotion

You can use the applications that are created by this blog writer Deku.
Deku created the applications with Flutter.

If you have interested, please try to download them for free.

Posts