I had a directory such that

$ ls
$ README.md testA.c testB.c a_large_folder another_folder

my most recent add->commit->push consisted of

$ README.md testA.c

Normally, my lazy self is used to doing git add . but this time I simply wanted to add a_large_folder.

When I did,

$ git add a_large_folder

I was prompted back fatal: pathspec 'a_large_folder' did not match any files. So of course I googled "git add folders" with the first SO answer saying to git add <folder>/*.

Well, I stupidly wrote git add a_large_folder\ (notice the wrong slash). This resulted in,


as if it executed an interpeter. I, again being stupid, wrote :q because I've been in vim all day so I wasn't thinking about whether that would actually quit or not.

Now, all of my files after my most recent commit are gone; aka only READ.md testA.c are left in my directory. The other stuff appears as if it's been rm -rf

Not a big deal but curious why this deleted my files/folders in this directory.


My guess: you did not have the directory a_large_folder inside when running git add.

This is the only reason for git add a_large_folder to report:

pathspec 'a_large_folder' did not match any files

The syntax is correct and works for either for specific files as well as for a containing directory. See add.c.

If you confirmed your second command which you split over several lines, it also failed with:

fatal: pathspec 'a_large_folder:q' did not match any files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.