Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Add: pathspec didn't match any files

Tags:

git

git-bash

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.

like image 635
Hanzo Hasashi Avatar asked Dec 09 '25 18:12

Hanzo Hasashi


2 Answers

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

like image 56
Wuelber Castillo Avatar answered Dec 11 '25 21:12

Wuelber Castillo


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.

like image 30
Jonti Saikia Avatar answered Dec 11 '25 21:12

Jonti Saikia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!