Git: fatal: The current branch has no upstream branch
A plain-words explanation of this Git message: what it means, the usual causes, and the steps that fix it.
The messagefatal: The current branch feature has no upstream branch.
Make the error yourself
Run with git version 2.56.0.windows.4. This is the smallest example we could find that shows it.
Setup used before these commands (a practice folder with no data)
export GIT_AUTHOR_NAME=Asha GIT_AUTHOR_EMAIL=a@example.com GIT_COMMITTER_NAME=Asha GIT_COMMITTER_EMAIL=a@example.com
git init -q --bare -b main remote.git
git clone -q remote.git work
cd work
echo 1 > f.txt
git add f.txt
git commit -qm first
git push -q origin main
git switch -q -c feature
echo 2 >> f.txt
git commit -qam second
cd workCommands
git pushGit prints (the real message)
fatal: The current branch feature has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin feature
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.Why it happens
A branch can be linked to a branch on the server, called its upstream. A plain git push or git pull uses that link. A branch that you created on your own computer has no link yet, because the server has never heard of it, so Git does not know where to push. It prints the exact command that you need, with the branch name filled in.
How to fix it
- Run the command Git suggests:
git push --set-upstream origin <branch>(short formgit push -u origin <branch>). - After that, plain
git pushandgit pullwork for this branch. - To always create the link automatically for new branches, run
git config --global push.autoSetupRemote true.
The corrected version
Commands
git push --set-upstream origin featureGit prints (the corrected version)
branch 'feature' set up to track 'origin/feature'.
To ./remote.git
* [new branch] feature -> featureHow to avoid it
Use -u the first time you push a new branch.
Questions
What does upstream mean?
It is the branch on the server that your local branch follows.
This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.