问题描述
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
效果: