在將本地的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