Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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


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?".

share|improve this answer
but how do I "clean" another person's remote when they do a pull? – Ilea Cristian Jul 1 '14 at 19:51
@IleaCristian due to the distributed nature of Git, you don't clean a remote, only your own clone. – VonC Jul 1 '14 at 20:19
The problem is that we don't make the final build. The project files (that the IDE sees) are actually some folders with "extension" (myproj.xcworkspace or myproj.xcodeproj). I wanted to remove the xcworkspace and leave only the xcodeproj. Basically I wanted to force the people that make the build to use only the xcodeproj file. – Ilea Cristian Jul 1 '14 at 20:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .