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

浏览:38日期:2023-09-22

问题描述

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

Admin@Administrator MINGW64 /d/htdocs/work.local.com/www-local-com (develop)$ git merge lernadoUpdating 764de39..7717317Fast-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 developTo 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 dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (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)

新手,求大神们指教

问题解答

回答1:

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

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

希望对你有帮助

回答2:

直接翻译这段英文,意思是远程的版本里除了你这个commit之外还有你本地没有的东西,要求你先git pull一下

回答3:

他提示你了,你要push到的分支上有你本地没有的commit,建议先git pull合并后再push.

回答4:

push 的时候远程分支很有可能别人已经提交了新的代码,所以你需要先pull下代码,使本地代码是最新的,如果存在冲突解决一下,然后再去push代码

相关文章: