please, 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'
CodePudding user response:
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.
CodePudding user response:
In order to push from your new local repository, you need to:
- make sure you have an empty newly created GitHub repository
- rename your local branch from master to main (check your Git version):
git branch -m master main
- execute
git config --global init.defaultbranch main
to use main from now on for any new local repository (since GitHub is also usingmain
by default) - add the remote GitHub repository URL as remote origin:
git remote add origin https://github.com/<me>/<myNewRepo>
- finally push:
git push -u origin main