Deply React application to GIthub

I am trying to follow the below link to deploy React app to Git hub.

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-react-part-ii/modules/fscp-deploy-a-react-application-with-netlify/articles/create-and-share-a-react-app-on-github

cd my-react-app
git remote add origin https://github.com/username/my-react-app.git
git branch -M main
git push -u origin main

However I get the following error message
error: src refspec main does not match any
error: failed to push some refs to ‘hfcheung001/jamming · GitHub

What should i do?

That warning commonly pops up when you try and push when no commits have been made within the repository.

It can occur under other circumstances- Message ‘src refspec master does not match any’ when pushing commits in Git - Stack Overflow but at a guess it’s that no commits have yet been made.

Thank you for your response. How do I commmit?
This is a new repository that I’d like to add to GitHub

Have you learnt any background to using git? It’s very much worthwhile if you’re using it.

For a commit at the very least you’d want to stage one or more files and then make a commit-

echo "some text" > test.txt
git add test.txt  # stage the file
git commit -m "an example"  # make snapshot

In your case I’d assume there are quite a few things you’d want to add.

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.