I have a folder with code files. I wanted to push them to github using git. This is what I've done:
I created a new repository on github.
I initialized a git repo in my local directory.
I staged my files.
I made my initial commit.
Then I run-
git remote add origin https://github.com/Lamphrangmi-Lamin/Bootcamp-Survey.git
It says on branch master
but I wanted it to be on 'main' branch instead.
After that I run this command-
git push -u origin main
8.And it shows me this-
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Lamphrangmi-Lamin/Bootcamp-Survey.git'
What I wanted was to have my files on the main
branch.
You need to create main
branch first:
git checkout -b main
git push -u origin main
You can then delete the old master
branch:
git branch -d master
For future, you can configure the name of git's default branch (assuming you are running version 2.28 or later):
git config --global init.defaultBranch main
You could also keep the branch named master
in your local repo, but push to main
on the remote side:
git push -u origin master:main