I have just started learing GIT. Follow their tutorial.
Now at the very beginning I got stuck with this error:
Fatal: pathspec \'file.txt\' did not match
Note: you shouldn't see this particular error message in git 1.9/2.0 (Q1 2014).
See commit 64ed07c by Nguyễn Thái Ngọc Duy (pclouds):
add
: don't complain when adding empty project rootThis behavior was added in 07d7bed (add
: don't complain when adding
empty project root - 2009-04-28, git 1.6.3.2)
then broken by 84b8b5d (remove match_pathspec()
in favor of match_pathspec_depth()
- 2013-07-14, git 1.8.5).
Reinstate it.
The idea is:
We try to warn the user if one of their pathspecs caused no matches, as it may have been a typo. However, we disable the warning if the pathspec points to an existing file, since that means it is not a typo but simply an empty directory.
Unfortunately, the
file_exists()
test was broken for one special case: the pathspec of the project root is just "".
This patch detects this special case and acts as if the file exists (which it must, since it is the project root).The user-visible effect is that this:
$ mkdir repo && cd repo && git init && git add .
used to complain like:
fatal: pathspec '' did not match any files
but now is a silent no-op.
It is again a silent no-op in upcoming git 1.9/2.0 (Q1 2014)
I was having the same issue but with the Windows file system. Here was my solution that worked.
from the git project directory. Here is exactly what was displayed with the current directory.
D:\Projects\ReactNative\project>git add "scr/\components/\validate.js"
The file being entered into git was validate.js. It was in a directory under the project. That directory was src\components.
Just give a file path while adding file to git add command, it works for me
$ git add mainFolder/.../file.extension
Note: mainFolder would be the folder inside your repo
I had the same problem because the file name is already appended with .txt and you are adding an extra .txt explicitly. You can try with this:
git add file.txt.txt
Here you go! Very simple. Need to place the .txt file manually in the pwd mentioned folder...
suumapat@SUUMAPAT-IN MINGW64 ~/newproject (master) $ git add abc.txt fatal: pathspec 'abc.txt' did not match any files
suumapat@SUUMAPAT-IN MINGW64 ~/newproject (master) $ dir
suumapat@SUUMAPAT-IN MINGW64 ~/newproject (master) $ pwd /c/Users/suumapat/newproject
suumapat@SUUMAPAT-IN MINGW64 ~/newproject (master) $ dir abc.txt
suumapat@SUUMAPAT-IN MINGW64 ~/newproject (master) $ git add abc.txt
Use double quotes in the file name as shown below and it should work perfectly.
Error:
fatal: pathspec 'index.html' did not match any files
Solution:
git add "file_name"