$ 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.
分析一下如何解决?
Did you make the submission on a different machine? ?
There are commits on the remote branch that do not exist in the local branch. This is often a problem encountered during multi-person collaborative development. You can
fetch
再merge
,也就是pull
,把远程分支上的提交合并到本地分支之后再push
first.If you are sure that those commits on the remote branch are no longer needed, then directly
git push origin master -f
force the local branch to overwrite the remote branch. . .The version of your remote library is newer than your local library. You need to git pull to update your local library before you can git push to the remote library~
To put it simply, your remote library has things that the local library does not have. It needs to be synchronized first, and then the contents of the local library can be pushed to the remote library~
Isn’t it very clear? . ?
Let you
fetch first
Just
git pull
first...It may be that your local warehouse data is inconsistent with the remote warehouse data. You must first capture and merge all the contents of the remote warehouse (git pull origin master), and then push the local warehouse data (git push origin master)