So, I encountered a very interesting annoyance yesterday with Git. I can't say that it was a problem since it is working as designed, and there is a solution.
I am tracking 7 different branches of Subversion in Git. What is really interesting, is that I actively work on most, if not all of those branches. When switching back and forth between branches, as you can imagine, there are some branches that has folders and code that other branches do not.
Git, by design, does not track folders. The side effect of this is that when I am working on Branch A that has a folder F, then I checkout Branch B, which does not have folder F, that folder F still remains. This is minor but it can quickly become very annoying especially when working in Java and there are a ton of empty packages (folders) in your source directory. So what do you do...?
There is a command that will clean up all of the files that are not part of your git repository - including the folders. This command is:
git clean -fd
Keep in mind, that any files or folders that are not part of the git repository will be removed when you issue this command. If instead, you would like to do a dry run and see what exactly would be deleted prior to actually deleting them, you can run
git clean -fdn