Push & pull problemsAlways fixable

Fix 'no upstream branch' and 'no tracking information'

Git says my branch has no upstream branch — what do I set and why?

If you’re seeing this error

fatal: The current branch <branch> has no upstream branch.
To push the current branch and set the remote as upstream, use: git push --set-upstream origin <branch>
There is no tracking information for the current branch.

You’re in the right place — the fix is below.

Short answer

A new local branch has no counterpart on the server, so plain git push and git pull do not know where to go. git push -u origin <branch> creates it and records the link in one step. To link an existing remote branch without pushing, use git branch --set-upstream-to=origin/<branch>.

quick fix
git push -u origin "$(git branch --show-current)"

Push the branch and record its upstream in one command

Does this match your situation?

  • 'fatal: The current branch feature/login has no upstream branch.'
  • 'There is no tracking information for the current branch.' when running git pull.
  • git status never says ahead or behind.
  • The branch exists on GitHub but your local copy still will not pull.

Step-by-step fix

  1. Push and set the upstream together

    This is the answer for a branch you created locally. -u (short for --set-upstream) creates the branch on the remote and writes the tracking relationship into .git/config, so every later push and pull works with no arguments.

    step 1
    git push -u origin feature/login
    
    # whatever branch you are on:
    git push -u origin HEAD
    
  2. Link to a branch that already exists remotely

    When the branch is already on the server — someone else created it, or you deleted and recreated your local copy — you want the link without pushing anything.

    step 2
    git fetch origin
    git branch --set-upstream-to=origin/feature/login feature/login
    git status
    
  3. See what is currently tracking what

    -vv shows every local branch with its upstream and how far ahead or behind it is. A branch with no upstream simply has nothing in that column, which makes the gap obvious at a glance.

    step 3
    git branch -vv
    git config --get-regexp '^branch\.'
    
  4. Make Git set it up automatically from now on

    Since Git 2.37 push.autoSetupRemote does exactly what -u does, on every first push of a new branch, without you remembering. It is the single best cure for this error.

    step 4
    git config --global push.autoSetupRemote true
    git --version        # needs 2.37 or newer
    
  5. Repoint a branch that tracks the wrong thing

    Common after renaming a branch, or when a fork tracks upstream instead of your own origin. The unset leaves the branch with no upstream at all, which is sometimes what you want.

    step 5
    git branch --set-upstream-to=origin/main main
    git branch --unset-upstream
    

Why this works

Local branches and remote branches are separate things that happen to share a name. Tracking is the deliberate link between them, stored as branch.<name>.remote and branch.<name>.merge in .git/config, and it is what lets a bare git push or git pull work out a destination on its own. Clone creates that link for the default branch and git switch creates it for a branch that already exists on the server — but a branch you invent locally has no counterpart anywhere, so Git refuses to guess. It could assume origin and the same name, and quite often be right; instead it stops and prints the exact command, because silently creating a branch on a shared server is a worse failure mode than one extra flag.

If that didn’t work

  • Check the remote is named what you think: git remote -v.
  • In a fork, the branch may exist on upstream but not on origin — push it to origin first.
  • If git fetch shows nothing, the remote branch may have been deleted; prune with git fetch -p.
  • 'no tracking information' on pull can also mean the upstream branch was renamed on the host.

How to stop it happening again

  • Turn on push.autoSetupRemote and never think about this again.
  • Use git push -u the first time you push any new branch.
  • Run git branch -vv occasionally to spot branches with no upstream before they surprise you.
  • Create branches with git switch -c <name> origin/<base> so the base is unambiguous.

Commands used in this guide

git push

Upload your commits to the remote repository.

git branch

List, create, rename and delete branches.

git fetch

Download new commits from the remote without changing any of your files.

git pull

Fetch from the remote and immediately integrate the changes into your branch.

git config

Read and write Git settings for one repo, your user, or the whole machine.

Still stuck?

Search the full command reference and every other rescue guide — there are 76 of them, covering everything from detached HEAD to force-push disasters.

Browse all guides →

Frequently asked questions

What does 'the current branch has no upstream branch' mean?

Your local branch has no recorded counterpart on the remote, so git push has no destination to infer. Run git push -u origin <branch> to create it on the server and store the link at the same time.

What is the difference between git push -u and git push?

-u (--set-upstream) additionally writes branch.<name>.remote and branch.<name>.merge into .git/config. Without it the push still works if you name the remote and branch explicitly, but the next bare git push or git pull will not know where to go.

How do I set an upstream without pushing?

git fetch origin first, then git branch --set-upstream-to=origin/<branch> <branch>. That is the right form when the branch already exists on the server and you only need the local link.

Can Git set the upstream automatically?

Yes, since 2.37: git config --global push.autoSetupRemote true. Every first push of a new branch then behaves as if you had passed -u, which removes this error entirely.

Why does git pull say there is no tracking information?

Same cause from the other direction — pull needs to know which remote branch to merge and has nothing recorded. Either set the upstream, or name it explicitly for one command: git pull origin main.

Related rescue guides

← All Git Rescue guides