github上传代码error: src refspec master does not match any error: failed to push some refs to ‘https://g

github上传代码至某空仓repository,有时候遇到报错。

完整的过程为:

echo "# psaData" >> README.md

git init

git add README.md

git config --global user.email "you@example.com" (可以去掉--global)

git config --global user.name "Your Name" (可以去掉--global)

git commit -m "first commit for your repo"

git status

git remote add origin https://github.com/{youre_account}/{youre_repo}.git

git push -u origin master

【注意】现在可能已经改为main,而不是master

下一次提交之前,一定要先同步本地与repository代码。

git pull origin master

如果要提交代码的repository不是空仓,则首先git clone将其下载下来。

随后从git add 本地文件 开始,config视情况而定。

git下载代码后,可以通过git status或git branch查看当前所在分支

可以通过git branch -a查看代码所有分支

通过git checkout -b other origin/other切换到其它分支

另外,如需rename repository的名字,可以到repository的Settings tab中。

  • 9
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值