modernator modernator - 24 days ago 6
Git Question

How to remove files in repository with git?

In my repository, there are some files that has same name, only difference is the first letter is capital or not, like products.sql and Products.sql.

I was made file with small letter when I created, but after I renamed it to first character capital. I didn't removed from my local computer, just renamed it and commited to git. But when I checked the repository, there are two of all, capitalized and not!

I want to remove "products.sql", not Products.sql only(Of course, they are in same path). I tried this:


git rm products.sql


but it removes Products.sql and products.sql both! I don't know why is it happening. As I know, by default, git is case-insensitive, so before I renamed the files, I was changed the git config to case sensitive to prevent those kind of happening, but looks like I totally failed.

Is there a way to remove those unnecessary files safely? I'm using Bitbucket so I can remove from web, but hey, there are plenty of them, and I want to remove them entirely at once.

It will be very appreciate to tell me some advice. Thanks!

Answer
git config --global core.ignorecase false

should fix it.

EDIT: This is odd, especially since you're not on windows. A solution would be to copy Products.sql to some other folder (not git controlled), then git rm, then copy back the file then commit.

Comments