Can't remove all files with "git rm -r -f {folder_name}" (Windows 10)

647 Views Asked by At

I'm working in a git repository on Windows 10, and I have a folder named "Client" - I'm trying to completely delete it and all files inside it from my local repository. I'm inside the branch that I want it deleted from, and I ran the following command:

git rm -r -f .\Client\

It removed a lot of the folders and files inside Client, but there are still folders and files left. So I tried running it again, and I get the following message:

fatal: pathspec '.\Client\' did not match any files

What gives??

2

There are 2 best solutions below

1
OhleC On BEST ANSWER

git rm won't touch untracked files, so it's possible that after a call to git rm, the directory remains in the working copy, possibly with some files still in it.

0
Spixmaster On

Git can only delete files which it tracks which means that they were once added and committed to the repository.

Therefore, I would suppose that git does not track these files and thus cannot remove them - in your case your folder "Client". Thus, you should be able to simply remove them with the UI (right click > Delete) or a system command (for linux rmdir -r ...) without git. The error you experience is misleading for the user as the file or folder does only not exist for git but not the OS.

Either way check your repository files with (select the proper branch at args[2]):

git ls-tree -r master --name-only