14

I had some files in my git named like this: "myCamelFile.rb" I just right clicked on my IDE and renamed them to all lower case so like "mycamelfile.rb" But when I do a git status I don't get any message that these are changed.

What should be done now?

5 Answers5

16

Step one: Rename them to some temp names such as "mycamelfile_temp.rb" Step two: Rename them back to "mycamelfile.rb" now all in lower case.

Bobak_KS
  • 556
  • 3
  • 10
  • 5
    @EricFromSouthPark Step 3: Profit! – usumoio Jul 12 '13 at 20:22
  • 4
    Ok that works, but you should have said that after first renaming (Step one), we should **commit**, and then rename again (step two). – Mohammed Noureldin May 06 '18 at 22:01
  • This answer makes git commit very messy when renaming multiple files. I would recommend the other answer by Someone instead. changing git config with "git config core.ignorecase false" – DeeMeow May 02 '23 at 03:10
15

You can just change this git config as follows:

git config core.ignorecase false

William Baker Morrison
  • 1,642
  • 4
  • 21
  • 33
Someone
  • 151
  • 1
  • 2
10

You can use this to rename a file in git. You will then need to stage and commit that change.

git mv application/view/old_file_name.php application/view/new_file_name.php

Here are the complete docs on the mv command: https://www.kernel.org/pub/software/scm/git/docs/git-mv.html

usumoio
  • 3,500
  • 6
  • 31
  • 57
  • ok but now if I browse to my folder on file system, I am seeing the all lower case file names...I just renamed them the normal way we rename any file....so still I can refer to their old name too? In order to use this command. –  Jul 12 '13 at 19:52
  • 3
    Unfortunately running `git mv` only once in a case insensitive environment will not cut it. You will need to do it in two steps. Take a look at http://stackoverflow.com/questions/3011625/git-mv-and-only-change-case-of-directory – Anthony Accioly Jul 12 '13 at 20:02
3

An additional tip which is not mentioned in the accepted answer:

Step one: Rename them to some temp names such as "mycamelfile_temp.rb" Step two: Rename them back to "mycamelfile.rb" now all in lower case.

After the first renaming (Step one), we should COMMIT, and then rename again (step two).

Mohammed Noureldin
  • 14,913
  • 17
  • 70
  • 99
3

to rename a file or folder needs below step:

first step is change git config on project & global:

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

then rename file or folder:

git mv -f myCamelFile.rb mycamelFile.rb
Mahdi Afzal
  • 729
  • 10
  • 14