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 // 把本地仓库的变化连接到远程仓库主分支
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章