git push报错: error: failed to push some refs to ‘[email protected]:xxx/xxx.git‘解决方法

git push的时候报错:

error: failed to push some refs to '[email protected]:xxx/xxx.git'

今天在把本地仓库push到远程仓库的时候,报错了。。。
就是这样:

在这里插入图片描述

或则是,使用 git gui 使用情况就是这样:

Pushing to git@github.com:************.git
To github.com:************.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '************.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.

 
  
  
 
查了几种解决方式都不太管用,最后发现是由于github 中的 README.md文件 不在本地代码目录中

检查了一下果然如此!

这时候可以通过 git pull --rebase origin master README.md文件克隆到本地库。

 
  
 

之后可以看到本地仓库中有 README.md 文件了~~

 
  
  
 
此时再执行 git push origin master 就可以完成上传到远程仓库的操作了
在这里插入图片描述

或使用git gui 来实现push:

最后:

参考:
(1):https://blog.csdn.net/qq_34842671/article/details/70916587
(2):https://blog.csdn.net/sinat_34937826/article/details/90512627

猜你喜欢

转载自blog.csdn.net/qq_41709378/article/details/107435985