Unable to link local repository to GitHub repository - fatal: pathspec 'README.txt' did not match any files

Hi everyone,

I am having issues with setting up my Git repository and linking it to GItHub. I am following the video below:

Link - Windows version

When I try to add a readme.txt file it states:

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

I believe I have successfully setup my username and email: Here is what my repository looks like in File Explorer:

Finally Git Bash is also returning the below error when I try to push something to my github reporitory:

$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to ‘’

I appreciate any help I can get!


JRB

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

Are you in the same directory as README.txt?

Yes I am. Image is below:

Hm, the image doesn’t show that readme.txt is in users? You would confirm with an ls command.

Even if the file hasn’t been modified, you should be able to git add the file if it’s in the directory.

@jrb0831 Try looking at these examples. I feel like one of these s going to help: https://stackoverflow.com/questions/4181861/message-src-refspec-master-does-not-match-any-when-pushing-commits-in-git

As for following videos… Yea, the thing is unless you can recreate the environment of the video perfectly, you can’t always assume the same results. In a way, it’s these detours that help one understand the structure a little bit better of what goes on.

1 Like

That was it. I had mistakenly named the file README.txt.txt :upside_down_face:

However when trying to push my repository to Git repository to GitHub I receive the below error:

I feel like I went wrong somewhere during my configuration but have no clue where. I’ve been following the video step-by-step.

Thank you for all your help!

I think that’s a case of updating your repo through github.com itself so that your online commit is now ahead of your local commit.

You’ll want to fetch that online commit and merge it with your own. Will add a little detail in a minute.

1 Like

If you don’t have important changes in your local commit you could just do a git pull followed by git push which would fetch the newest commits from your online repo and automatically merge them with your local commit (most of the time this is fine anyway with the standard merge methods) followed by a push of the newly merged commits to your remote repo. This is probably the best choice for now unless you wanted to do some extra reading.

If you want to be extra cautious you can use git fetch to get the updated versions without an automatic merge. You’ll find them as branches prepended with the name you use for your pull remote (in this case origin) so master for example would be origin/master. You can then use them like a normal branch and check merge options in detail .e.g --dry-run to be sure your merge is safe.

Thanks for the information but I think I might be misunderstanding something. I’ve ran git pull and followed it up with git push which seem to run without error. I believe this is pulling everything from my existing online repository down to my local repository and then I am pushing it all back up (keeping everything in sync). However I still cannot run:

$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/xxx/git_practice.git'

Ooh sorry, that’s not what I thought it was. I’d have a look at this SO query to see if any of it covers your issue-

1 Like

That worked! All I had to do was commit something!

Tyvm

1 Like