git提交远程库报错failed to push some refs to “git“ - git push报错

git提交远程库(push)报错

在这里插入图片描述

错误代码:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'codehub.devcloud.cn-north-4.huaweicloud.com:xgfz-jd-gh-zy17jjdsx-B600001/jQueryDemo.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.

错误原因:远程库中的README.md文件不在本地代码目录中

在这里插入图片描述

解决方法:

通过命令:git pull --rebase origin master进行代码合并
在这里插入图片描述
执行命令之后,本地代码库会出现README.md文件和.gitignore文件
在这里插入图片描述

再次push推送远程库成功:
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40542534/article/details/108658010