Hanzo Hasashi
Hanzo Hasashi

Reputation: 121

Git Add: pathspec didn't match any files

I'm trying to add new files to my working directory and then register them by doing this:

git add filename.php

Yesterday I just double-checked on the remote gitlab location and all the new files from yesterday have been included.

However, now whenever I'm adding new files I get this error:

pathspec filename.php didn't match any files

If I do git status, it confirms that the new files are not being registered.

ls - new files are not showing up although they are physically located in the specific folder.

I haven't made any changes to gitignore or any other settings for that matter and I've double-checked that I'm in the right folder and on the right branch.

Upvotes: 3

Views: 7823

Answers (2)

Jonti Saikia
Jonti Saikia

Reputation: 21

Don't use space between the filename if similar name is used. As for example if you already add a file named as test.txt then don't use test 2.txt. Rather you can rename it as test_2.txt.

Upvotes: 2

Wuelber Castillo
Wuelber Castillo

Reputation: 196

If you do git status, does it show all the path to the file? like /path/to/filename.php. If this is the case, I always put all the path in git add like git add /path/to/filename.php

Upvotes: 8

Related Questions