➜ /myrepo git:(master) git add index.html
fatal: pathspec 'index.html' did not match any files
If you are trying to add a file to staging area using git command and you get the fatal pathspec did not match any files error, well reason could be one of the below,
- The file that you are trying to add to the staging area does not exist.
- You have misspelled the filename.
- You are in the wrong branch.

You can run the git staus command to check if the file exists or the correct name of the file in the untracked list of files,
➜ /myrepo git:(master) ✗ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
sample.txt
nothing added to commit but untracked files present (use "git add" to track)
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!