$ git push origin master
To git@github.com:qzmly100/repository-.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:qzmly100/repository-.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.
分析一下如何解決?
是不是在不同的機(jī)器上上做了提交??
遠(yuǎn)程分支上存在本地分支中不存在的提交,往往是多人協(xié)作開(kāi)發(fā)過(guò)程中遇到的問(wèn)題,可以先fetch
再merge
,也就是pull
,把遠(yuǎn)程分支上的提交合并到本地分支之后再push
。
如果你確定遠(yuǎn)程分支上那些提交都不需要了,那么直接git push origin master -f
,強(qiáng)行讓本地分支覆蓋遠(yuǎn)程分支。。。
你的遠(yuǎn)程庫(kù)的版本比你的本地庫(kù)要新,需要先git pull 更新你的本地庫(kù)后才能git push到遠(yuǎn)程庫(kù)里~
簡(jiǎn)單說(shuō)就是你的遠(yuǎn)程庫(kù)里有了本地庫(kù)沒(méi)有的東西,需要先同步,然后才能把本地庫(kù)內(nèi)容推送到遠(yuǎn)程庫(kù)里~
不是說(shuō)的很明確了嘛。。?
讓你fetch first
就是先git pull
一下...
可能是你本地倉(cāng)庫(kù)數(shù)據(jù)和遠(yuǎn)程倉(cāng)庫(kù)數(shù)據(jù)不一致,要先抓取并合并遠(yuǎn)程倉(cāng)庫(kù)全部?jī)?nèi)容(git pull origin master),再推送本地倉(cāng)庫(kù)數(shù)據(jù)(git push origin master)