I am trying to remove a folder from my Git repository with
git rm folderToRemovebut Git issues this error when I try to do so.
fatal: pathspec 'siteFiles/applicationFiles/templates/folderToRemove'
did not match any filesMy 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?
1 Answer
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 -fdHowever:
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 addbeforegit clean.
Run rather first a:
git clean -d -x -nAs explained in "How do I clear my local working directory in git?".
3