Pathspec Did Not Match
Error message
fatal: pathspec 'filename' did not match any files
Quick summary
You referenced a file that Git cannot find — it does not exist in the working directory or is not tracked.
Why this happens
Typo in the filename
The file does not exist in the current directory
The file is ignored by .gitignore
You are in the wrong directory
Minimal example
git add readme.md # fatal: pathspec 'readme.md' did not matchgit add README.md # correct capitalizationThe file is named README.md (uppercase), not readme.md. Filenames are case-sensitive — fix the spelling.
How to diagnose
Check the file exists with ls or dir
Verify the spelling and path
Run git status to see tracked files
Check if the file matches a .gitignore pattern
How to fix
Correct the filename spelling or path
Navigate to the correct directory with cd
If the file is ignored, use git add -f to force-add it
Create the file if it does not exist
How to prevent
Use tab-completion for filenames to avoid typos
Verify file paths with ls before running git commands