! [rejected] master -> master (non-fast-forward) error: failed to push some refs to ‘xxx’
今天新建了一个仓库,并未push代码,然后按提交代码的流程提交项目时,报错
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'xxx'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
经过百度后发现原因是仓库中有readme文件,而项目中没有,内容不同步造成的,但是我明明执行过下面命令拉取过代码。
git pull origin master
后来查百度又执行下面语句后成功在本地同步了readme文件
git pull --rebase origin master //本地生成ReadMe文件
之后再次提交,还是报这个错,再次百度,最后执行下面这条命令,意思是可以允许不相关历史提交,强制合并。文章来源:https://www.toymoban.com/news/detail-527513.html
$git pull origin master --allow-unrelated-histories
最后成功提交。文章来源地址https://www.toymoban.com/news/detail-527513.html
到了这里,关于git报错:[rejected]master->master(non-fast-forward)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!