git 錯誤error:failed to push some refs to

今天使用VSCODE 學習node.js, 想在git上push代碼 於是在git上建立了一個私有的遠程倉庫, 連接後push代碼時提示如下錯誤:

error: failed to push some refs to '[email protected]:…" Updates were rejected because the remote contains work that you do not have locally.

This is usually caused by another repository pushing to

大概原因就是 意思是本地和遠程的文件應該合併後才能上傳本地的新文件

使用菜單上的 同步 推 拉 都無法解決,

截圖如下
F:\game_project\node_project>git push -u origin master
To https://gitee.com/cn_xxxxx/node.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/cn_xxxxx/node.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.

解決方案

先拉下來,會自動合併的(不用操心)
git pull origin master

2、再上傳

git push -u origin master

成功解決問題

特此記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章