学无先后,达者为师

网站首页 编程语言 正文

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

作者:jack@london 更新时间: 2022-04-11 编程语言

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中。

原文链接:https://blog.csdn.net/figosoar/article/details/108635030

栏目分类
最近更新