modernator modernator - 25 days ago 12
Git Question

How to remove files which differ in capitalization in a Git repository?

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 made a file with small letter when I created, but later I renamed it to first character capital. I didn't remove it from my local computer, just renamed it and committed 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 both
Products.sql
and
products.sql
! 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.

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