I\'m trying to push one of my projects to github, and I keep getting this error:
fatal: The current branch master has no upstream branch.
I\'ve
Some people coming to this page may simply have this error because they did git push origin
and simply didn't realise that you need to specify the remote branch name as well, as in git push origin master
.
If you do git branch --set-upstream-to=origin/master master
a reference is added to .git\config to link the local and remote branches. I presume that then you no longer need to specify the branch name when pushing to the remote.
In case someone is still running into this issue, this command solved it for me
git push --set-upstream origin master
I had this problem today on my own remote repository, not Github and realized I had not made any commits to my local repository before trying to push to the remote repository.
git add -A
git commit
git push origin master
Create the repo on github; add a README file on github and then clone the github repository. Creating the README file (or any file actually) is needed in order to get a master branch.
Notice how github prompts for creating a README when creating a repository:
You need to configure the remote first, then push.
git remote add origin url-to-your-repo
instructions
Cool Blue's answer ALMOST worked for me.
First I did: "git branch --set-upstream-to=origin/master master", as recommended by Cool Blue.
But still received error message:
"failed to push some refs to ''
hint: Updates were rejected because the tip of your current branch is behind its remote counterpart. Integrate the remote changes (e.g. 'git pull ...') before pushing again."
So I... did a "git push -f" command after the git branch, which worked finally worked for me.
After the forced push, subsequent "git push" commands worked without issue.