之前在gitHub上弄好了SSH並成功推送過一次,今天推送的時候報錯
$ git push origin master
To git@github.com:ZhuYutao/learngit.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'git@github.com:ZhuYutao/learngit.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.
錯誤訊息中有原因。
在你這次push之前,有其他人push到了伺服器上。你本地不是最新的。
你需要先git pull一下,然後在push。
樓上是一個解決辦法,還可以強制提交
在每次提交的時候還是git pull 再git push 這個是習慣吧 否則會出現上述情況