fatal: The current branch master has no upstream branch

后端 未结 23 2217
误落风尘
误落风尘 2020-11-30 16:46

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

peeplesoft@jane3:~/846156 (master) $ git push

fatal: The current branch mas         


        
相关标签:
23条回答
  • 2020-11-30 17:06

    commit your code using

    git commit -m "first commit"
    

    then config your mail id using

    git config user.email "example@example.com"
    

    this is work for me

    0 讨论(0)
  • 2020-11-30 17:07

    There is a simple solution to this which worked for me on macOS Sierra. I did these two commands:

    git pull --rebase git_url(Ex: https://github.com/username/reponame.git)
    git push origin master
    

    If it shows any fatal error regarding upstream after any future push then simply run :

    git push --set-upstream origin master
    
    0 讨论(0)
  • 2020-11-30 17:07

    To resolve this issue, while checking out the code from git itself, u need to give the command like below:

    git checkout -b branchname origin/branchname

    Here, by default we are setting the upstream branch, so you will not be facing the mentioned issue.

    0 讨论(0)
  • 2020-11-30 17:10

    Apparently you also get this error message when you forget the --all parameter when pushing for the first time. I wrote

    git push -u origin
    

    which gave this error, it should have been

    git push -u origin --all
    

    Oh how I love these copy-paste errors ...

    0 讨论(0)
  • 2020-11-30 17:10

    If you define the action git push it should take it if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line.

    Just do it:

    git config --global push.default current
    

    then

    git push
    
    0 讨论(0)
  • 2020-11-30 17:10

    I also got the same error.I think it was because I clone it and try to push back. $ git push -u origin master This is the right command.Try that

    Counting objects: 8, done. Delta compression using up to 2 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (8/8), 691 bytes | 46.00 KiB/s, done. Total 8 (delta 1), reused 0 (delta 0) remote: Resolving deltas: 100% (1/1), done.

    • [new branch] master -> master Branch master set up to track remote branch master from origin.

      It was successful. Try to create new u branch 
      
    0 讨论(0)
提交回复
热议问题