git出現的錯誤彙總及解決方法


git錯誤彙總

錯誤一:Updates were rejected because the remote contains work that you do

執行命令:

git push -u origin master

出現錯誤:

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'xxx.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.

原因分析:

因爲我們在本地新建庫後,與遠程倉庫的內容不一致導致的。爲此在我向遠程庫推送的時候,要先進行pull,讓本地新建的庫和遠程庫進行同步。

解決方法:

# 注:這裏master應該修改成自己push的倉庫
git pull origin master // 把本地倉庫的變化連接到遠程倉庫主分支
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章