Reputation: 75
My branch in the Github repository is "master". In the terminal I did:
git branch
and the output is:
* main
my-temporary-work
I wanted to push a file to Github and I used:
git add exploratory_analysis.ipynb
git commit -m "New version"
git push origin master
The "git add" and "git commit" commands work. However, the last command (i.e., "git push origin master") does not work, and I get this error:
error: src refspec master does not match any
error: failed to push some refs to '[email protected]:NAME-OF-USER/REPOSITORY-NAME.git'
That is, it looks like I cannot push any code from my laptop to Github. How can I fix it?
Upvotes: 0
Views: 3560
Reputation: 5834
I faced the same issue some days ago.
If you created a new repository nowadays(2020) then the default branch in main
on GitHub.
you can check on GitHub now in your repository branches.
so that's why you need to run
git push origin main
instead of
git push origin master
Goodluck with more details you can watch video
Upvotes: 3
Reputation: 187
Why are you pushing to master if the branch commands outputs main? Try 'git push origin main'
Also found this explanation for the change: https://stackoverflow.com/a/65008828/1959534
Upvotes: 0