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 (ie, "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 'git@github.com: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?
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.