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.
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
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.
- Delete the folder that is "hanging" outside, for example delete "Widget/ScoialIcons"
- Stage the change in VS
- Copy the folder back
- Stage again and now you should see only file(s) in the mismatched casing folder
- Commit and push, you should now see the folder go away
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.