git上的版本和本地版本冲突的解决方法 failed to push some refs to

使用git创建项目,然后本地 git init
然后没有执行 git pull -f --all
然后git add . | git commit -m “”
有时候会导致git push -u origin master失败
导致github上的版本里有readme文件和本地版本冲突

To https://gitee.com/shishuiwuhen/RedRabbitIOS.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/shishuiwuhen/RedRabbitIOS.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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 --rebase origin master,进行代码合并,但是这个方法并不管用,尝试了很多其他的方式都不行。最后只有通过强制覆盖现有的分支来解决这个提交失败的问题:
git push -u origin master -f

你可能感兴趣的:(Git)