常见git错误

通常在不熟悉git操作及其相关的原理情况下,遇到常见的git错误茫然不知所措,简单的办法是删库重来。该文将会描述push不能正常工作等错误

错误描述:

error: failed to push some refs to 'https://github.com/YSZYCF/Machine-Learning-Book-Resource.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.

解决办法:

git pull origin master

原因:

通常本地仓库向远程仓库推送的时候,需要本地仓库和远程仓库建立连接(即本地和远程仓库需要保持一致),在没有建立连接的情况下,会报当前的错误