fatal: The current branch master has no upstream branch

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 https://github.com/You/YourRepo)

For https url:

If your account is protected by the two-factor authentication, your regular password won’t work (for https url), as explained here or here.

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 

Why?

  • HEAD (see your .git\HEAD file) has the refspec of the currently checked out branch (for example: ref: refs/heads/master)
  • 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.

Leave a Comment