git push 报错为fatal: The current branch master has no upstream branch. To push the current branch and

本文详细解释了在初次使用Git时遇到的fatal错误:“The current branch master has no upstream branch.”的原因及解决办法。主要针对初次推送代码到GitHub仓库时,由于仓库中只有一个master branch而引起的错误。提供了三种解决方法,包括初始化仓库、设置远程仓库并推送master分支。
摘要由CSDN通过智能技术生成

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
来删除远程库

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值