Posted By: Anonymous
I’m trying to push one of my projects to github, and I keep getting this error:
[email protected]:~/846156 (master) $ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master
So I tried it and got this:
[email protected]:~/846156 (master) $ git push --set-upstream origin master fatal: Authentication failed
Another stackoverflow thread suggested I try the following, with disappointing results.
[email protected]:~/846156 (master) $ git push -u origin master fatal: Authentication failed
Then I tried this:
[email protected]:~/846156 (master) $ git config remote.origin.push HEAD [email protected]:~/846156 (master) $ git push fatal: Authentication failed
You fixed the push, but, independently of that push issue (which I explained in “Why do I need to explicitly push a new branch?“:
git push -u origin master or
git push -u origin --all), you need now to resolve the authentication issue.
That depends on your url (ssh as in ‘
[email protected]/yourRepo, or https as in
For https url:
Same problem if your password contains special character (as in this answer)
If https doesn’t work (because you don’t want to generate a secondary key, a PAT: personal Access Token), then you can switch to ssh, as I have shown here.
As noted by qwerty in the comments, you can automatically create the branch of same name on the remote with:
git push -u origin head
- HEAD (see your
.gitHEADfile) has the refspec of the currently checked out branch (for example:
- the default push policy is simple
Since the refpec used for this push is head: (no destination), a missing
:<dst> means to update the same ref as the
<src> (head, which is a branch).
That won’t work if HEAD is detached though.