Reputation: 13
Can someone tell me how to solve this: When I execute git init
I only see (master) not (master->origin) and, when I do git branch, it returns nothing and when I try to push I get this error:
git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'github.com:BghAek/something.git'
Upvotes: 0
Views: 2174
Reputation: 1324367
In order to push from your new local repository, you need to:
git branch -m master main
git config --global init.defaultbranch main
to use main from now on for any new local repository (since GitHub is also using main
by default)git remote add origin https://github.com/<me>/<myNewRepo>
git push -u origin main
Upvotes: 1
Reputation: 83527
After git init
, you need to commit the code with git add .
and then git commit -m "Initial commit"
. Then you will be able to git push
if your repository has a remote that points to GitHub or some other online service.
I strongly encourage you to learn the basics of git. Pro Git is a good place to start. The first three chapters explains the fundamental concepts that you will use regularly. The remaining chapters get into more advanced concepts if you need them later.
Upvotes: 2