dev@local: ~/project — git
dev@local~/project$git add index.js
error: pathspec did not match any file
Diagnostics Translation
Git could not find the file or directory you specified in your command.
waiting for resolution...
LowVersion Control System
Reviewed for reference consistency: April 11, 2026
Code is Safe
SECUREGit has paused the operation to protect your code. No data has been lost or corrupted.
What To Know
This parser failure means Git could not map the supplied file-style argument to anything tracked or present in the expected scope.
Where Did It Fail?
Working Tree
Your local files
add
Staging Index
Prepared changes
commit
Local Repo
Commit history
push/fetch
Remote Server
GitHub/GitLab
Git halted to protect the uncommitted files in your active working directory.
Commands That Trigger This
$git add index.js
Running when the file is actually named `index.ts`
$git checkout -- file.txt
Running for a file that was never tracked
Technical Background
01
This error simply means Git's search returned zero results. It acts as a guardrail before Git treats the request as a real file-targeting operation.
02
Because pathspecs can use wildcards (like `*.txt`), the error can also occur if no files match the provided pattern.
Underlying Causes
Typo in the file path
The file was already deleted or moved
The file is ignored by `.gitignore`
Frequently Asked Questions
The file might be ignored by your `.gitignore` file, or you might be running the command from a different subdirectory.
Related Git States
sparse-checkout-leaves-no-entryMedium
Your sparse-checkout rules excluded all files, leaving your working directory empty.
ambiguous-argumentLow
Git doesn't know whether you are referring to a branch name or a file path.
unknown-revision-or-path-not-in-working-treeLow
Git could not parse your input as a valid commit, branch, or file path.