Why is there no "pathspec" when I try to remove a folder in Git?

I am trying to remove a folder from my Git repository with

git rm folderToRemove

but Git issues this error when I try to do so.

fatal: pathspec 'siteFiles/applicationFiles/templates/folderToRemove' 
did not match any files

My current directory is "templates." I am finding this error odd since I can cd into the folder "folderToRemove," so it clearly exists. What does this error mean?


Solution 1:

Git doesn't version directories, only "content" (directory content or files)

did not match any files

That means there is no file to remove within folderToRemove, as I mention in "Unable to remove files recursively from Git".
You now can remove (Windows del or Unix rm) the directory itself.

As described in "Deleting empty directories in Git", you can also run a:

git clean -fd

However:

Warning: The clean command removes any files in the current working copy that aren’t being tracked by git. This is a good way to lose your work if you haven’t added new files to git. Always run git add before git clean.

Run rather first a:

git clean -d -x -n

As explained in "How do I clear my local working directory in git?".