Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git master branch has no upstream branch

Tags:

git

github

I'm trying to push one of my projects to github, and I keep getting this error:

fatal: The current branch master has no upstream branch. 

I've never seen this before. I re-initialized my git, re-added my origin, deleted and re-made the repo, and recreated my SSH key.

like image 571
JShoe Avatar asked May 11 '13 03:05

JShoe


People also ask

What does it mean when a branch has no upstream branch?

The fatal: The current branch master has no upstream branch error occurs when you have not configured git in such a way that it creates a new branch on the remote. Therefore, you are only creating a new branch on the local computer.

How do I get upstream branch?

The easiest way to set the upstream branch is to use the “git push” command with the “-u” option for upstream branch. Alternatively, you can use the “–set-upstream” option that is equivalent to the “-u” option. As an example, let's say that you created a branch named “branch” using the checkout command.

What is an upstream branch?

What is Git Upstream Branch? When you want to checkout a branch in git from a remote repository such as GitHub or Bitbucket, the “Upstream Branch” is the remote branch hosted on Github or Bitbucket. It's the branch you fetch/pull from whenever you issue a plain git fetch/git pull basically without arguments.


1 Answers

Instead of creating a new repository on Github, cloning that, or reinitializing your local repository, the following command would have been sufficient:

git push -u origin master 

origin stands for the remote name (default is origin),
master is the branch you want to push, in your case it's master, otherwise you would have to change that in the command.
-u means, that your local branch will be setup to track the new created master branch on the origin repository (the master on the origin will be the upstream branch of your local branch). If the branch master doesn't exist on the remote repository, it will be created, otherwise it will be updated (the -u works no matter if it exists or not).

like image 97
dunni Avatar answered Sep 23 '22 09:09

dunni