git push 报错为fatal: The current branch master has no upstream branch. To push the current branch and set the remote as upstream, use
To push the current branch and set the remote as upstream, use)
原因
小伙伴在第一次使用git的时候,因为github中没有创建仓库或者仓库里只有一个master branch , 提交时就会显示:当前分支上面没有分支 。
解决办法
1.我们可以新建一个仓库:
代码如下:
git init
git add test00.c
git commit -m “first commit”
git remote add origin https://github.com/pony-2020/test.git
git push -u origin master
2.如果仓库已经存在
git remote add origin https://github.com/pony-2020/test.git
git push -u origin master
3.可以使用 git remote rm origin
来删除远程库
本文详细解释了在初次使用Git时遇到的fatal错误:“The current branch master has no upstream branch.”的原因及解决办法。主要针对初次推送代码到GitHub仓库时,由于仓库中只有一个master branch而引起的错误。提供了三种解决方法,包括初始化仓库、设置远程仓库并推送master分支。
425

被折叠的 条评论
为什么被折叠?



