Problem faced
I had the same problem when I was creating a new repository on GitHub and linking it with my React app in the client computer I have.
I used the following steps:
Commands used before the problem
git init
git commit -m "first commit"
git branch -M main
git remote add origin "_git repository link here_"
git push -u origin main
My mistake
But as you can see, my mistake was not using the git add .
command.
I did this mistake, because I already had the README.md file and GitHub instructs us with basic commands while creating the repository.
My solution
My solution is to use git add .
after the git init
command.
Use the following set of commands in the same order to overcome the problem:
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin "_git repository link here_"
git push -u origin main
git add
with dot or some files this error also will appear.