Search code examples
gitversion-controlcase-sensitive

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?


Solution

  • 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