- To get practice with Github, I created a new directory on my computer that I wanted to push to Github.
- I added a .csv file and nothing else.
- I created a new repo on Github without initializing a README.
- I cd'd into the directory then used the following commands in Terminal:
git init
git add file1.csv
git commit -m "First commit"
git remote add origin <Github url from Quick Setup page>
git push -u origin main
And I got the following errors:
error: src refspec main does not match any
error: failed to push some refs to <url>
I searched for a solution and I came across this: git error: failed to push some refs to remote The answer selected says:
If the GitHub repo has seen new commits pushed to it, while you were working locally, I would advise using:
git pull --rebase origin master
git push origin master
What I don't understand is, why did this happen with a new directory on my computer and a new repo? No commits were made to the repo on Github so why should I have to git pull
? I even tried doing this with a new empty directory and new empty repo (again) and I got the same result.