在推送本地上 GitHub 跳出以下錯誤

$ git push -u origin master
To https://github.com/abc/docker-git-lab.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/abc/docker-git-lab.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.

滿低級問題,原因大概是我在 GitHub 建 repository 時,勾了產出 README.md
就先把遠端合併回來再推上去,或強制把本地推上去

合併回來
$ git pull -r
推上去
$ git push -u origin master
或
$ git push -f

參考來源: 另一種合併方式(使用 rebase)【狀況題】怎麼有時候推不上去…

另外 Gitlab 分支保護設定也會影響到無法推上去,需要推到其他分支再發 Merga Request 合併進去

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *