Git's Hate for Folder Names Beginning with a Dash

April 2012 · 1 minute read

I was working on HTML wireframes last night for a client and I was using a ”-” (dash) as a folder name to store CSS, images, and JS. This also kept it ordered at the top of the file list.

You get the idea.

I needed to delete a file from the repo inside the dash folder so I tried:

$ git rm -/imgs/logo.png

However, git threw and error:

error: unknown switch `/’

After digging around for 20 minutes I realized that git must think the “-” was a parameter instead of a folder name. I tried escaping it and wrapping the path name in single quotes, but no luck. I ended up having to rename the folder to an underscore, but with the absolute path.

$ git mv /Users/blainsmith/Sites/client-website/-/ /Users/blainsmith/Sites/client-website/_/

Once I renamed it all was well. Now I know why it was changed to an underscore, just completely forgot.