Git 远程推送报错:[rejected] master -」 master (fetch first) error: failed to push some refs to ‘

完整报错信息

背景:这个项目以前在 Github 上推送过一次,现在想推送到 Gitee 。

Git 推送远程仓库时,出现如下报错:

To gitee.com:wangjiabin-x/light-mvvm.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to '[email protected]:wangjiabin-x/light-mvvm.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: '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

然后再执行推送命令:

git push origin master

成功。

猜你喜欢

转载自blog.csdn.net/weixin_44198965/article/details/107290807