我的想把我的个人分支修改的代码更新到公共的开发分之中,我把我的分支合并到本地开发分支之后,想通过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 分支
,保证本地和远程为同一版本在更新就没问题了。你执行如下命令之后再试试看希望对你有帮助
直接翻译这段英文,意思是远程的版本里除了你这个commit之外还有你本地没有的东西,要求你先
git pull
一下他提示你了,你要push到的分支上有你本地没有的commit,建议先git pull合并后再push.
push 的时候远程分支很有可能别人已经提交了新的代码,所以你需要先pull下代码,使本地代码是最新的,如果存在冲突解决一下,然后再去push代码