git:fatal the current branch master has no upstream - Go语言中文社区

git:fatal the current branch master has no upstream


一直是这个错!!!

git本地仓库push远程仓库的时候,报了异常:fatal the current branch master has no upstream branch
经过查询发现目前有两种解决方案:

1.翻译后大致意思是,远程仓库创建时候要建立一个README文件,然后再进行push操作。因为这个文件是远程仓库主分支所必须的,见如下截图。

Create the repo on github; add a README file on github and then clone the github repository. Creating the README file (or any file actually) is needed in order to get a master branch.Notice how github prompts for creating a README when creating a repository:

2.翻译后大致意思是,如果不想重新创建远程仓库再克隆(针对方案1),或者初始化本地仓库,可以使用下面命令: git push -u origin master,其中origin 表示远程仓库名称,master是远程仓库的push目标分支。-u (推测为update缩写^_^~)表示本地分支将建立对远程仓库目标分支的检测,如果远程仓库目标分支不存在,将新建分支再push;如果存在,将进行push更新。

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

最后用第二种方法 搞定!

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/q406226321/article/details/78983542
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2019-09-01 19:04:55
  • 阅读 ( 1182 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢