git 合并分支后更新到远程报错

查看:379
本文介绍了git 合并分支后更新到远程报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

我的想把我的个人分支修改的代码更新到公共的开发分之中,我把我的分支合并到本地开发分支之后,想通过push更新到远程,结果出错了,而且最近经常遇到。如下是我出错的信息

Admin@Administrator MINGW64 /d/htdocs/work.local.com/www-local-com (develop)
$ git merge lernado
Updating 764de39..7717317
Fast-forward
 controllers/ListsController.php | 1 -
 1 file changed, 1 deletion(-)

Admin@Administrator MINGW64 /d/htdocs/work.local.com/www-local-com(develop)
$ git push origin develop
To git@git.develop.com:admin.site/www-develop-com.git
 ! [rejected]        develop-> develop (fetch first)
error: failed to push some refs to 'git@git.develop.com:admin.site/www-develop-com.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.

Admin@Administrator MINGW64 /d/htdocs/work.local.com/www-local-com (develop)

新手,求大神们指教

解决方案

我觉得你本地的开发分支develop可能不是最新的,就是和远程的开发分支develop不是同一版本。这种问题我遇到过,一般你在执行git push origin 分支之前最好执行一下git pull origin 分支,保证本地和远程为同一版本在更新就没问题了。你执行如下命令之后再试试看

#先执行
git pull origin develop
#在执行
git push origin develop

希望对你有帮助

这篇关于git 合并分支后更新到远程报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆