Unfuddle STACK Tips & Tricks
How to fix Git error: The current branch has no upstream branch.
An upstream branch is a remote branch that is being tracked by a local branch.
Depending on how the
push.default config is set, you may encounter the following error.
# attempt to push while the current branch # does not track any upstream branch $ git push fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin master
The fix is rather simple and is already suggested by the failing command: use
--set-upstream option when pushing
$ git push --set-upstream origin master ... To https://url-to-remote-origin 1561943..f8357d9 master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.
This is only needed once. From now on, our local
master branch is set to pair with the upstream
master branch. When we push, Git will know where to push the changes:
$ git push Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Delta compression using up to 8 threads Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 349 bytes | 349.00 KiB/s, done. Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 To https://url-to-remote-origin f8357d9..c29db9a master -> master
Check the Full Official Documentation for more options.