gitseverity: can-fix
no upstream

git push fatal: The current branch has no upstream branch

No upstream branch set for the current branch

100% fixable~1 mindifficulty: beginner

Verified against git 2.47 docs (git-push.html), Stack Overflow #6089294 (top answer, 5.3k upvotes) · Updated April 2026

> quick_fix

Your local branch has no tracking relationship to a remote branch. Use `git push -u origin <branch-name>` (or just `git push -u origin HEAD`) to push and set the upstream in one command.

# Push and set upstream in one command
git push -u origin HEAD

# Or explicitly name the branch
git push -u origin feature/new-thing

What causes this error

When you create a local branch with `git checkout -b newbranch`, git does not automatically set an upstream (tracking) relationship to a branch on any remote. On your first push, git refuses because it doesn't know where to push — it needs you to specify the remote (usually `origin`) and, by convention, the same branch name.

> advertisementAdSense placeholder

How to fix it

  1. 01

    step 1

    Run git push with the -u flag

    The -u (short for --set-upstream) tells git to remember this remote and branch as the upstream for all future pushes and pulls from this local branch.

    git push -u origin HEAD
  2. 02

    step 2

    For future pushes

    Once the upstream is set, you only need `git push` and `git pull` — git remembers the relationship.

  3. 03

    step 3

    Optional: make this the default

    Run `git config --global push.default current` so every new branch auto-sets its upstream on first push, eliminating this error forever.

    git config --global push.default current
    # With this, `git push` on a new branch just works.

Frequently asked questions

Why does git not set the upstream automatically?

Historical default — git wanted you to opt in. Newer versions have push.default=simple which is closer to the behaviour most people want, but you still need -u on the first push.

Can I set the upstream after pushing?

Yes — `git branch --set-upstream-to=origin/mybranch` (no push required if the remote branch already exists).

disclosure:Errordex runs AdSense and has zero affiliate links or sponsored content. Every fix is manually verified against official sources listed in the “sources” sidebar. If a fix here didn’t work for you, please email so we can update the page.