How to fix current branch xxx has no upstream branch.

When you create a new branch and trying to push the new commit then you will be seeing this error

$ git push
fatal: The current branch feature/addEODRepohas no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature/addEODRepo

To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.

How to fix current branch xxx has no upstream branch.

  • run this command to tell git to create remote upstream branch automatically every time you push
    --global will apply to all git commands on your machine not only this repo.
git config --global --add --bool push.autoSetupRemote true

Reference


Discover more from naiwaen@DebuggingSoft

Subscribe to get the latest posts to your email.