Rejected git push

一曲冷凌霜 提交于 2019-12-21 05:04:08

问题


To git@github.com:xxx/xxxxx.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:xxx/xxxxx.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

I got this error when I tried to push some changes. When I try to fetch from repo i get

From github.com:xxx/xxxxx
 * branch            master     -> FETCH_HEAD

What should I do to solve this ? It's been basically just me on the repo so far, I've had just two pushes from someone else. Do I need to do a proper merge ?


回答1:


The push is failing because your refs are behind those of the remote repository. The fetch operation only brings down the contents and refs of the remote repository but does not update your refs to the changes. Hence it does nothing to resolve the problem preventing the push. You'll need to either do a pull operation or manual merge with the local version of the remote refs.



来源:https://stackoverflow.com/questions/3945080/rejected-git-push

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!