Reputation: 803
I am trying to push files to GitHub main repo as the master branch name is changed to main, but after
git init >
and git remote add >
as git initialized a master branch on my local,
how to push change and push to main check the error below.
$ git push origin/main main
error: src refspec main does not match any.
error: failed to push some refs to 'origin/main'
Upvotes: 1
Views: 224
Reputation: 59923
I would suggest you change the upstream branch for your local master
to origin/main
with the --set-upstream-to
option:
git switch master
git branch --unset-upstream
git branch --set-upstream-to origin/main
From that point on, you can just use the regular git pull/git push
from your master
branch and Git will interact with the main
branch on the origin
remote.
If you like to keep things in sync, you can also rename your local master
branch to main
with the --move
option:
git branch --move master main
Upvotes: 1
Reputation: 7622
Several solution
Change default branch name
git config --global init.defaultBranch main
Create a main branch
git checkout -b main
Push your master branch to the origin main
git push origin/main master
Upvotes: 1