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>.
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
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 1git push -u origin feature/login # whatever branch you are on: git push -u origin HEADLink 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 2git fetch origin git branch --set-upstream-to=origin/feature/login feature/login git statusSee 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 3git branch -vv git config --get-regexp '^branch\.'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 4git config --global push.autoSetupRemote true git --version # needs 2.37 or newerRepoint 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 5git 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 pushUpload your commits to the remote repository.
git branchList, create, rename and delete branches.
git fetchDownload new commits from the remote without changing any of your files.
git pullFetch from the remote and immediately integrate the changes into your branch.
git configRead 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
git push fails with 'src refspec main does not match any' — what does that mean?
You asked Git to push a branch that does not exist locally. Either you have made no commits yet — a repository with zero commits has no branches at all — or your branch is called master and you are pushing main. Run git log --oneline and git branch to see which, then commit or rename.
Read the fix →Always fixablegit pull says I need to specify how to reconcile divergent branches — what do I choose?
Git 2.27+ refuses to guess whether you want a merge or a rebase when both sides have new commits. Pick one — git config --global pull.rebase true gives you clean linear history and is the best default for most people.
Read the fix →Always fixableHow do I rename a Git branch?
git branch -m <new-name> renames the branch you're on. Renaming on the server takes two more steps, because Git has no rename operation for remote branches — you push the new name and delete the old one.
Read the fix →Usually recoverableHow do I delete a remote branch in Git?
git push origin --delete <branch> removes it from the server. Deleting it locally with git branch -d doesn't touch the remote at all, and other people keep seeing stale copies until they run git fetch --prune.
Read the fix →