fatal: pathspec 'README.txt' did not match any files

Really getting stuck on this one. I've googled a lot and can't figure out what I've done wrong...

I'm trying to create a new file, via the git add README.txt command in terminal...

(So far I've created a new folder Fundamentals. Created a sub-folder git-practice. And created a git repo via git init command)

However, when I try and add a file in fundamentals/git-practice, i get the following error..

fatal: pathspec 'README.txt' did not match any files

Not sure what I'm doing wrong.. everything seems to make sense. Here's the code:

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$ 
2

6 Answers

I'm trying to create a new file, via the 'git add README.txt' command in terminal...

git add does not create a new file. It adds an existing file to be indexed by git. You'll need to create the file first.

2

Just type in your terminal (e.g. in git bash):

git >> README.md
git add README.md

fatal: pathspec 'README.txt' did not match any files

You get this error because there is no file named README.txt in the current directory. Git is in the business of managing files that you create with other programs, usually a text editor or IDE. git add only adds the file to the index. It does not create any files directly. You need to use another tool to do so. Use your favorite text editor (I suggest Notepad++, Sublime Text 3, or Atom) and create a file with some text.

I had the same problem and after typing ls I had git display all the files I had in the folder, then I found that I had saved the readme file as readme.txt.txt. Hence I had to rename the file to readme.txt and then I was able to add it successfully.

I do following this command (windows10) in terminal and everthing is working

  • git init git add README.txt git commit -m "first commit" git remote add origin So I create my token in github then git push origin master

The following code works for me

git add README.txt
0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like