Git branch-has-no-upstream Git does not know which remote branch should receive your pushed commits.

dev@local: ~/project — git
dev@local~/project$git push
fatal: branch has no upstream
To push the current branch and set the remote as upstream, use:
git push --set-upstream origin current-branch
Diagnostics Translation
Git does not know which remote branch should receive your pushed commits.
waiting for resolution...
LowVersion Control System

Reviewed for reference consistency: April 11, 2026

Code is Safe

SECURE

Git has paused the operation to protect your code. No data has been lost or corrupted.

What To Know

This message means your local branch exists only in local history terms, without a paired remote-tracking reference that Git can use for default push behavior.

Where Did It Fail?

Working Tree
Your local files
add
Staging Index
Prepared changes
commit
Local Repo
Commit history
push/fetch
Remote Server
GitHub/GitLab
Git halted to protect the uncommitted files in your active working directory.

Commands That Trigger This

$git push
Running immediately after creating a branch with git checkout -b new-feature
$git pull
Trying to on a local branch that was never linked to a remote counterpart
A team member creates a feature branch locally, works on it for hours, then runs git push expecting it to upload -- but receives the upstream error because the branch has no remote tracking reference

Technical Background

01

Git requires explicit instructions for the first push of a new branch to prevent accidentally publishing private local branches.

02

Once the upstream link is established (usually via the `--set-upstream` or `-u` flag), future `git push` commands will work automatically without needing the branch name.

03

Git branching model is deliberately local-first: when you create a branch with git checkout -b, it exists only in your local repository. Git does not automatically publish it to any remote. This design prevents accidental publication of work-in-progress branches and gives the developer explicit control over which branches exist on the remote. The upstream tracking link is what tells Git which remote branch corresponds to your local branch, enabling shorthand commands like git push and git pull to work without specifying a remote and branch name each time.

Underlying Causes

Pushing a newly created local branch for the first time without specifying the remote destination
The remote branch you were tracking was deleted
Cloning a repository without fully setting up local tracking branches

Frequently Asked Questions

Because you might want to push your local branch to a differently named branch on the server, or keep it strictly local. Git asks for confirmation the first time.

The local branch retains a stale upstream reference pointing to a remote branch that no longer exists. Git push will fail with a different error (remote-rejected or src-refspec-does-not-match-any), while git pull may produce a warning. The upstream link can be removed with git branch --unset-upstream.

Yes. Running git config --global push.default current tells Git to push the current branch to a remote branch of the same name. Combined with git config --global autoSetupRemote true (Git 2.37+), new branches will have their upstream set automatically on first push.

Related Git States