Fix "fatal: The current branch has no upstream branch"

Your branch only exists on your computer, so git doesn't know where to push it. Run git push -u origin <branch-name> once: it creates the branch on GitHub and links the two, so plain git push works from then on.

Step by step

  1. Push the new branch and set its upstream:

    $ git push -u origin croissant
  2. From now on:

    $ git push

-u is short for --set-upstream. You can also make it automatic with git config --global push.autoSetupRemote true.

Try it in the interactive sandbox →Practice “Set the upstream” with a real repository and teammates, right in your browser.

Related guides