致命:pathspec';file.txt';与任何文件都不匹配,GIT
我刚刚开始学习GIT。遵循他们的教程 现在一开始我就被这个错误所困扰:致命:pathspec';file.txt';与任何文件都不匹配,GIT,git,Git,我刚刚开始学习GIT。遵循他们的教程 现在一开始我就被这个错误所困扰: Fatal: pathspec 'file.txt' did not match any files. 以下是我的过程和命令的屏幕截图: 我做错了什么 文件不存在,因此无法添加它们。确保先创建文件 D:\temp\hi>git init Initialized empty Git repository in D:/temp/hi/.git/ D:\temp\hi>dir Volume in drive D
Fatal: pathspec 'file.txt' did not match any files.
以下是我的过程和命令的屏幕截图:
我做错了什么 文件不存在,因此无法添加它们。确保先创建文件
D:\temp\hi>git init
Initialized empty Git repository in D:/temp/hi/.git/
D:\temp\hi>dir
Volume in drive D is Data
Volume Serial Number is 744F-7845
Directory of D:\temp\hi
2013-11-25 12:59 AM <DIR> .
2013-11-25 12:59 AM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 1,331,387,256,832 bytes free
D:\temp\hi>git add hi.txt
fatal: pathspec 'hi.txt' did not match any files
D:\temp\hi>echo hello > hi.txt
D:\temp\hi>git add hi.txt
D:\temp\hi>dir
Volume in drive D is Data
Volume Serial Number is 744F-7845
Directory of D:\temp\hi
2013-11-25 12:59 AM <DIR> .
2013-11-25 12:59 AM <DIR> ..
2013-11-25 12:59 AM 8 hi.txt
1 File(s) 8 bytes
2 Dir(s) 1,331,387,256,832 bytes free
D:\temp\hi>git init
已在D:/temp/hi/.Git中初始化空Git存储库/
D:\temp\hi>dir
驱动器D中的卷是数据
卷序列号是744F-7845
D:\temp\hi的目录
2013-11-25 12:59上午。
2013-11-25 12:59。。
0个文件0个字节
2个目录133187256832字节可用
D:\temp\hi>git add hi.txt
致命:pathspec“hi.txt”与任何文件都不匹配
D:\temp\hi>echo hello>hi.txt
D:\temp\hi>git add hi.txt
D:\temp\hi>dir
驱动器D中的卷是数据
卷序列号是744F-7845
D:\temp\hi的目录
2013-11-25 12:59上午。
2013-11-25 12:59。。
2013-11-25 12:59 AM 8 hi.txt
1个文件8个字节
2个目录133187256832字节可用
为了将文件添加到git,它必须存在git add
不会创建文件,但会告诉git将其添加到您所在的当前分支并跟踪它
从git status
命令可以看出,当前没有跟踪的文件。为了跟踪我的项目目录中的所有文件,请执行一个git add my project/*
。这将添加该目录中的所有文件
接下来,如果没有所需的file.txt,只需创建一个文本文件并运行
git status
。它应该显示您有一个未跟踪的file.txt文件,您可以使用git add file.txt
将其添加到git 注意:您不应该在git 1.9/2.0(2014年第1季度)中看到此特定错误消息
见:
add
:添加空项目根目录时不要抱怨
此行为已添加到(add
):添加时不要抱怨
空项目根目录-2009-04-28,git 1.6.3.2)然后被打破(删除
match_pathspec()
以支持match_pathspec_depth()
-2013-07-14,git 1.8.5)
恢复它
这个想法是: 如果用户的某个路径规格没有导致匹配,我们会尝试警告用户,因为这可能是输入错误。但是,如果pathspec指向现有文件,则禁用警告,因为 这意味着它不是打字错误,只是一个空目录 不幸的是,
文件\u exists()
测试因一种特殊情况而中断:项目根目录的路径规范仅为“”。此修补程序检测到这种特殊情况,并将其视为文件存在(它必须存在,因为它是项目根) 用户可见的效果是: 习惯于抱怨,比如: 但现在是无声的禁止
在即将发布的git 1.9/2.0(2014年第1季度)中,这又是一个无声的禁止操作。我也被这个问题困扰着。解决办法是: a) 先创建任何txt文件,比如“Readme.txt” b) 将此文本文件复制到本地git repo(文件夹)例如-C:/store c) 如果您在windows上,请转到windows命令提示符(单击窗口按钮时在搜索栏上键入“cmd”) d) 转到您当地的git回购。键入**echo hello>Readme.txt** --->C:\admin\store>echo hello>Readme.txt
echo hello是一个dos命令,它向屏幕或文件显示输出状态文本。要将文件添加到git,它必须存在
git add
不会创建文件,但会告诉git将其添加到您所在的当前分支并跟踪它。因此,您应该在命令行中创建一个新文件:
MD <new file>
MD
然后,添加:
git add <new file>
git添加
我也遇到了同样的问题,因为文件名已经附加了.txt,而您正在显式添加一个额外的.txt。您可以尝试以下方法:
git add file.txt.txt
该文件不匹配,因为
git add
在根目录中创建了您的文件,但实际上没有创建文件,而是告诉git将其添加到您所在的当前分支(将文件从工作目录添加到临时区域),并使用git status
命令跟踪它。所以
首先创建.txt文件并正确提及路径强>
让我们有
$ git add path/filename.txt
(不限于此,对于任何git命令,如果要在暂存区中进行更改,请在命令后用前向斜杠写入文件名的整个路径)
e、 g-
如果你的文件在桌面上,那么
$ git add C:Users/username/Desktop/filename.txt
我在做:
git add AppName/View Controllers/Sections/Devices/DeviceContainerViewController.swift
但是出现以下错误:
致命:pathspec“AppName/View”与任何文件都不匹配
正如您所看到的,由于存在空间,该命令在视图和控制器之间中断
我只需要把我的路径用双引号括起来。这通常是不必要的,但当你有空间的时候,你需要
git add "AppName/View Controllers/Sections/Devices/DeviceContainerViewController.swift"
给你!很简单。需要将.txt文件手动放置在pwd提到的文件夹中 suumapat@SUUMAPAT-在MINGW64~/newproject中(主) $git add abc.txt 致命:pathspec“abc.txt”与任何文件都不匹配 suumapat@SUUMAPAT-在MINGW64~/newproject中(主) $dir suumapat@SUUMAPAT-在MINGW64~/newproject中(主) $pwd /c/Users/suumapat/newproject suumapat@SUUMAPAT-在MINGW64~/newproject中(主) $dir abc.txt suumapat@SUUMAPAT-在MINGW64~/newproject中(主)
$git add abc.txt我也遇到了同样的问题,但是Windows文件系统。这就是我的解决方案 从git项目目录。下面就是当前目录显示的内容 D:\Projects\ReactNative\project>git添加“scr/\components/\validate.js”
输入git的文件是validate.js。它在项目下的一个目录中。该目录是src\components 我也有同样的问题。请确认您的文件目录。 在mov之后
git add AppName/View Controllers/Sections/Devices/DeviceContainerViewController.swift
git add "AppName/View Controllers/Sections/Devices/DeviceContainerViewController.swift"
touch filename
git add filename
fatal: pathspec 'index.html' did not match any files
git add "file_name"