Error when setting GitHub - first remote repository

I’m doing the Git course.
I have a GitHib account and I have installed Git bash

In ‘Your first remote repository on GitHub’ I have done no 1- 5 of the instructions. In no 6 I have copied the lines in ‘… or push an existing …’ but when I run the lines in Git bash I get an error


: git remote add origin
: git branch -M main
: git push -u origin main
error: src refspec main does not match any
error: failed to push some refs to ‘

Can someone please help me what to do? Thanks

Are there any commits on that branch at present? I think this reply and the link contained within it might be useful for you-

I had the same problem and ended up following the instructions under “Adding a project to GitHub without GitHub CLI” here.

This appeared to work but I am curious if this is the best approach.