DEV Community

Cover image for [git notes] Fix `git push -u` The current branch has no upstream branch error
Mauricio Carvalho
Mauricio Carvalho

Posted on

[git notes] Fix `git push -u` The current branch has no upstream branch error

The error bellow happens everytime that I need to push a brand new brach to a remote git server using the command git push -u.

fatal: The current branch <branchname> has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin <branchname>
Enter fullscreen mode Exit fullscreen mode

Git needs to configure the push strategy to auto create a remote mirror of your new branch automatically. The command to do that is:

 git config --global push.default current
Enter fullscreen mode Exit fullscreen mode

That's it!

For more details, you can check the docs here

Top comments (0)