DEV Community

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

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

oak profile image Mauricio Carvalho ・1 min read

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

Discussion (0)

pic
Editor guide