美文网首页
如何解决failed to push some refs to

如何解决failed to push some refs to

作者: 阿鲁提尔 | 来源:发表于2018-03-19 23:57 被阅读0次

描述:
我在做项目的时候,把README.md文件给改名了。
git push上传的时候,出现以下报错

To git@github.com:ls506507881/cv.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:ls506507881/cv.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

----------------------------------------------------------------------------

借用翻译器
To git@github.com:xxx/xx.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xxx/xx.git'
//错误:push到这个仓库失败了

hint: Updates were rejected because the remote contains work that you do
提示:更新被拒绝,因为远程包含您所做的工作。

hint: not have locally. This is usually caused by another repository pushing        
提示:本地没有。这通常是由另一个存储库推送引起的。

hint: to the same ref. You may want to first integrate the remote changes
提示:同样的参考文献。您可能需要首先集成远程更改。

hint: (e.g., 'git pull ...') before pushing again.
提示:(例如,‘git拉...’)之前再推。

hint: See the 'Note about fast-forwards' in 'git push --help' for details.
提示:有关细节,请参阅“git推送--帮助”中的“关于快速转发的注意事项”。

好吧。。。还是不知道怎么解决,于是百度查找别人是怎么解决的。。

1.没有本地的README.md文件

新建README.md文件,再次上传,还是报错。

2.尝试把当前分支代码上传到master分支上。
$ git push -u origin master

但依然没能解决问题

3.、github中的README.md文件不在本地代码目录中

可以通过如下命令进行代码合并【注:pull=fetch+merge]

git pull --rebase origin master
//执行代码后可以看到本地代码库中多了README.md文件

此时再执行语句 git push -u origin master即可完成代码上传到github

相关文章

网友评论

      本文标题:如何解决failed to push some refs to

      本文链接:https://www.haomeiwen.com/subject/dsbmqftx.html