致命:pathspec'README.txt'与任何文件都不匹配

Ree*_*rma 5 git

真的陷入了这个问题.我已经google了很多,无法弄清楚我做错了什么......

我正在尝试通过git add README.txt终端中的命令创建一个新文件...

(到目前为止,我已经创建了一个新文件夹Fundamentals.创建了一个子文件夹git-practice.并通过git init命令创建了一个git repo )

但是,当我尝试添加文件时fundamentals/git-practice,我收到以下错误..

fatal: pathspec 'README.txt' did not match any files
Run Code Online (Sandbox Code Playgroud)

不知道我做错了什么......一切似乎都有道理.这是代码:

Reenas-MBP:~ reenaverma$ cd ~

Reenas-MBP:~ reenaverma$ ls
72.png          GitHub          flask-workshop
Applications        Library         fundamentals
Creative Cloud Files    Movies          funny_things
Desktop         Music           get-pip.py
Documents       Pictures        world
Downloads       Public          wwlc
Dropbox         Retrieved Contents

Reenas-MBP:~ reenaverma$ cd fundamentals

Reenas-MBP:fundamentals reenaverma$ ls
git-practice

Reenas-MBP:fundamentals reenaverma$ cd git-practice

Reenas-MBP:git-practice reenaverma$ ls -a
.   ..  .git

Reenas-MBP:git-practice reenaverma$ pwd
/Users/reenaverma/fundamentals/git-practice

Reenas-MBP:git-practice reenaverma$ git add README.txt
fatal: pathspec 'README.txt' did not match any files

Reenas-MBP:git-practice reenaverma$ 
Run Code Online (Sandbox Code Playgroud)

小智 14

只需在终端中输入(例如在 git bash 中):

git >> README.md
git add README.md
Run Code Online (Sandbox Code Playgroud)


eis*_*eis 12

我正在尝试通过终端中的'git add README.txt'命令创建一个新文件...

git add不会创建新文件.它添加了一个由git索引的现有文件.您需要先创建文件.

  • @javan.rajpopat 真的吗?只需“触摸 README.txt” (2认同)

Cod*_*ice 10

致命:pathspec 'README.txt' 不匹配任何文件

您收到此错误是因为README.txt当前目录中没有命名的文件。Git 负责管理您使用其他程序(通常是文本编辑器或 IDE)创建的文件。git add只将文件添加到索引中。它不直接创建任何文件。您需要使用其他工具来执行此操作。使用您最喜欢的文本编辑器(我建议使用 Notepad++、Sublime Text 3 或 Atom)并创建一个包含一些文本的文件。