! [rejected] master -> master (fetch first)

在将本地的master分支首次部署到远程的gitlab上面时,我们用git push -u origin master 命令执行报错如下:

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'ssh://git@g.hz.netease.com:22222/XXXXX/fastmonkey.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.

出错的原因:gitlab中READE.md文件不在本地代码目录中
解决方法: $ git pull
--rebase origin master $ git push origin master

 

此时就可以了:    

 

注意:

   push之前需要先pull代码合并一下,再去push

 

posted on 2019-08-23 15:10  不怕风雨的向日葵  阅读(2367)  评论(0)    收藏  举报

导航