➜ /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)
-
Have Questions? Post them here!
More Posts related to Git,
- [Fixed] Git Clone git@github.com: Permission denied (publickey) Could not read from remote repository Fatal error
- Github: How to Invite Collaborators
- Git Commit - Author identity unknown, Please tell me who you are email
- [Solution] fatal: not a git repository (or any of the parent directories): .git
- [fix] zsh: command not found: git
- Github: fatal: Authentication failed Support for password was removed on August 13, 2021
- Get List of all local branches git command
- Git Revision Questions Before the Interview
- git fatal: Authentication failed error [fix]
- How to Install Git on Ubuntu Linux
- GitHub: How to Search Code
- How to change Git Default Author and Committer details in Eclipse
- How to check your installed version of Git
- Install GitHub Command Line Tool on Mac
- How to Merge Branch into Master Branch
- Perform an Empty Commit in Git without anything in Staging Area
- Git Fix: fatal: refusing to merge unrelated histories Error
- How to undo last Git Commit on Local Repository?
- git command to remove/unstage files from staging area
- Step-by-Step: Setting up Docker + Ubuntu Linux + Git + GitHub Tutorial
- Remove git config at Local, Global or System Levels?
- Fix [oh-my-zsh] Cant update: not a git repository
- Git Config Command - A Deep Dive
- fatal: Unable to create '/c/git_repo/.git/index.lock': File exists. If no other git process is currently running, this probably means a git process crashed in this repository earlier.
- How to change directory in Git bash
More Posts:
- [Solution] macOS Big Sur Installation: There is not enough free space, Additional Space Required - MacOS
- error: file not found: HelloWorld.java - Java
- Change color of macOS terminal prompt - MacOS
- Only Chessboard using HTML and CSS Code Example - CSS
- How to Cut Copy and Paste in Nano Text Editor - Linux
- Android : Unable to load VM from snapshot : Mac OS X Error - Android
- Convert Java Object to JSON using Jackson Library - Java
- How to rerun last command in Zsh shell - HowTos