Git master branch has no upstream branch

前端 未结 10 739
北荒
北荒 2021-01-30 16:53

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

相关标签:
10条回答
  • 2021-01-30 17:20

    Try both the HTTP and SSH urls? I had a problem when I was using the SSH url but, when I switched to the HTTP one, it worked like a charm.

    Here is what I changed:

    First, view the remote URL

    git remote -v 
    

    and you get destinations back.

    git remote rm destination 
    

    Follow this link if you need help: https://help.github.com/articles/removing-a-remote/

    Then,

    git remote add origin url 
    git push -u origin master
    
    0 讨论(0)
  • 2021-01-30 17:24

    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).

    0 讨论(0)
  • 2021-01-30 17:24

    The following command worked for me:

    git branch --set-upstream-to=origin/master master
    
    0 讨论(0)
  • 2021-01-30 17:25

    i faced the same problem just tell github to use the current head branch of your local repository:

    git push --set-upstream origin master
    

    wish it help you and others

    0 讨论(0)
提交回复
热议问题