Reputation: 1685
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$
Upvotes: 17
Views: 62434
Reputation: 161
Just type in your terminal (e.g. in git bash):
git >> README.md
git add README.md
Upvotes: 16
Reputation: 83577
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.
Upvotes: 11
Reputation: 9
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 https://github.com/your_github/github_project.git So I create my token in github then git push origin master
Upvotes: 0
Reputation: 1
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.
Upvotes: 0
Reputation: 53553
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.
Upvotes: 23