当前位置:   article > 正文

git push 推送至远程仓库发生报错_to the same ref. you may want to first integrate t

to the same ref. you may want to first integrate the remote changes

git push origin master
To https://gitee.com//hello-git.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/
/hello-git.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.

这个错误是因为你本地的仓库与远程仓库中的内容不同步,需要先拉取远程仓库的最新代码合并到本地仓库再进行 push 操作。你可以运行以下命令来解决该问题:

git pull origin master --allow-unrelated-histories
该命令将从远程仓库拉取最新代码并合并到本地仓库中。如果出现冲突,需要手动解决冲突后再进行提交。

然后再运行 git push origin master 命令即可将本地代码推送到远程仓库。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/733334
推荐阅读
相关标签
  

闽ICP备14008679号