0

Every changes are pushed perfectly except i have file name CompleteController.cs c in upper case in but in my git repo it is showing CompleteController.cs c in lower case.

Killer
  • 219
  • 3
  • 7
  • I recommend deleting the file locally and checking it back out to see if you can get a quick fix. If not... you'll need to locally, manually rename it. – whoisj May 29 '15 at 17:13

2 Answers2

1

You're probably on Windows, hence your filesystem is case insensitive. Hence you can't trust the case you see on your filesystem.

To fix it you can try

git mv -f <name-on-your-filesystem> <name_with_the_correct_case>

So if I understood clearly, it should be

git mv -f COMPLETECONTROLLER.cs CompleteController.cs
gturri
  • 13,807
  • 9
  • 40
  • 57
  • To be clear, NTFS is what you want it to be: Win32 elects to be case preserving. It is not completely case insensitive. – whoisj May 29 '15 at 17:13
-1

Git has a configuration setting that tells it whether to be case sensitive or insensitive: core.ignorecase. To tell Git to be case-senstive, simply set this setting to false:

git config core.ignorecase false

Documentation

From the git config documentation:

core.ignorecase

If true, this option enables various workarounds to enable git to work better on filesystems that are not case sensitive, like FAT. For example, if a directory listing finds makefile when git expects Makefile, git will assume it is really the same file, and continue to remember it as Makefile.

The default is false, except git-clone(1) or git-init(1) will probe and set core.ignorecase true if appropriate when the repository is created.

Rename the file back to the original name and then use the git mv function to "move" the function to the "new" name.

Example:

ls -la // display: Completecontroller.cs
git mv Completecontroller.cs CompleteController.cs
git status

// Now you should see the renamed file as renamed and not as unchanged.

Why can't i simply rename files under git?

The reason is that does not track files but content. Git does not care what is the name of the file, its calculating the SHA-1 from the content without the name and the name is kept else where (in the *.idx file and not in the pack file).

How to rename file under git?

As explained above git does not store the name of the file with the content. Look at the attached image, the pink section stores the content while the blue section is the "metadata" of the content, so in order to rename the file you must tell git to rename it in its internal storage the blue section)

enter image description here

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • Careful; Git's case insensitivity is dependent on [a specific configuration value](http://stackoverflow.com/a/8482021/1079354) which is usually governed by your OS (and subsequently your file system). – Makoto May 29 '15 at 14:38
  • I'm not sure what you're quoting from. If "Git is incase sensitive." is your own text, don't present it as a quote. If it isn't your own text, include some form of attribution in your answer. –  May 29 '15 at 14:40
  • i did not phrase it correctly, by **default** git is case sensitive unless you set up the desired config value. Fixed the answer – CodeWizard May 29 '15 at 14:45