当前位置: 代码迷 >> 综合 >> 2021-06-16 解决在git仓库界面直接删改文件造成的关于“error: failed to push some refs to ‘https://gitee.com/xxx.git‘“的报错
  详细解决方案

2021-06-16 解决在git仓库界面直接删改文件造成的关于“error: failed to push some refs to ‘https://gitee.com/xxx.git‘“的报错

热度:96   发布时间:2023-12-19 13:11:49.0
问题描述
PC@DESKTOPMINGW64 ~/Desktop/project (master)
$ git push -u wj master
To https://gitee.com/xxx.git! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/xxx.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.
出现原因

在git仓库界面直接删改文件造成与本地仓库不同步

解决方法
1.下载当前gitee仓库上的代码,再添加待上传的文件(实际上就是重新再连接远程仓库)

代码:

git pull origin master
git push origin master
2.强制覆盖当前本地仓库到gitee上

代码:

git push origin master -f 

效果:
在这里插入图片描述

  相关解决方案