Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is git not case sensitive?

In the first commitment of my partial called _Electronics it was written beginning with a capital letters, then I changed it to _electronics.

Git under cygwin ignored the case after commiting the new name, so I changed the name by hand in the target repo.

Now it sometimes changes the commited _electronics partial to _Electronics.

What have I done wrong?

like image 452
JAkk Avatar asked Dec 12 '11 22:12

JAkk


People also ask

Is git case-sensitive for file names?

Git is case-sensitive and your filesystem may not be - Weird folder merging on Windows - Scott Hanselman's Blog.

Is git case-sensitive for folder names?

Git is a unix based code. its is case sensitive so it will allow you to have the same name in different cases, and as you except windows will not be tolerated for this. There is nothing you can do about it beside renaming your folders.

Are GitHub organizations case-sensitive?

The organization name. The name is not case sensitive.


2 Answers

It is going to depend on the core.ignorecase configuration value, which is set to false in case-sensitive filesystems and true in msysgit on Windows.

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.

More detail in this reply to Changing capitalization of filenames in Git.

like image 158
manojlds Avatar answered Oct 22 '22 22:10

manojlds


It will be seen as 2 different things but will cause you issues on a non-case-sensitive system. If this is the case, ensure you are tab-completing any paths or file names. Further, to change the name of something in just the case, do this:

mv file.txt temp.txt git add -A git commit -m "renaming..." mv temp.txt File.txt git add -A git commit --amend -m "Renamed file.txt to File.txt" 

This is an explicit way of making changes committing them, then collapsing the commits. A shorter way to do it is to manipulate the index and working folder all in one:

git mv file.txt temp.txt git mv temp.txt File.txt git commit -m "Renamed file.txt to File.txt" 

This is related to adjusting directory names as well: git mv and only change case of directory

like image 35
Adam Dymitruk Avatar answered Oct 22 '22 21:10

Adam Dymitruk