Git is case-sensitive as a result extra folders show up in my GitHub repo

I noticed some "extra" folders in my repo on GitHub, but everything looks correct on my local repo. These folders contain other files/folders when you click into them on GitHub but they don't show up on my Windows local file system.

GitHub repo shows extra folders
GitHub repo shows extra folders

I later found out that Scott Hanselman ran into the exact same problem when he worked on his blog. He wrote a post with a good explanation on the cause of the matter. 

If you're not careful, you or someone on your team can create a case sensitive file path in your git index while you're using a case insensitive operating system like Windows or Mac. If you do this, you'll be able to end up with two separate entries from git's perspective. However Windows will silently merge them and see just one.

So, I must have at some point used a lower case folder name for plugins, themes and widgets, and honestly I don't remember. To Windows "plugins" and "Plugins" folders are the same folder, but to Git they are different folders and it remembers them as such. But when I pull the code locally, Windows silently merges the folders that Git thinks different into one. That is why I see "extra" folders online but not at my local.

According to this SO answer, since Git v1.5.6 there is an ignorecase option available in the [core] section of .gitconfig file. The default value is ignorecase = true and you want to be very careful to turn this value to false, as another SO answer warns.

I tried turning core.ignorecase to false for just my particular repo by running the following.

git config core.ignorecase false

It resulted in all the files in those 3 highlighted folders modified, the changes seemed to be just some text formatting changes. I made a commit on that and you can see for yourself what changes it did to my files. Unfortunately it did not solve my problem, the folders were still there on GitHub after I pulled this commit.

Then I read this SO answer and this SO answer with a proposal, the process does not involve messing around with core.ignorecase. These are my steps to get my issue fixed.

  1. Delete the folder that is "hanging" outside, for example delete "Widget/ScoialIcons"
  2. Stage the change in VS
  3. Copy the folder back
  4. Stage again and now you should see only file(s) in the mismatched casing folder 
  5. Commit and push, you should now see the folder go away
Staged Changes for file in casing mismatched folder
Staged Changes for file in casing mismatched folder

Another fix is to use git mv which I didn't try but Scott mentioned in his post "If you're renaming a directory, you'll do a two stage rename with a temp name."

git mv foo foo2
git mv foo2 FOO
git commit -m "changed case of dir"

In many situations, to solve a problem is to be able to correctly name the problem! I didn't know my issue was related to case-sensitivity in git, so I googled along the lines of "extra folders show up in github repo" and didn't find my answer. So, I posted a question on StackOverflow and others helped point me to the right direction.