Home › Git

fatal: The current branch has no upstream branch. — how to fix

fatal: The current branch feature-x has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature-x

Quick fix: Run git push -u origin HEAD (or git push --set-upstream origin feature-x). To never see this again: git config --global push.autoSetupRemote true.

What it means

A plain git push pushes to the branch's upstream (the remote branch it tracks). A branch you just created locally has none yet, so Git doesn't know where to push.

Fix

git push -u origin HEAD

-u (--set-upstream) links the branch, so later git push and git pull work without arguments. HEAD means "the current branch", so you don't have to type its name.

Make it automatic (Git 2.37+)

git config --global push.autoSetupRemote true

Now the first git push on a new branch creates and tracks the remote branch by itself.

Check what a branch tracks

git branch -vv

Link an existing remote branch without pushing:

git branch --set-upstream-to=origin/feature-x

Last updated 2026-10-27.