当前位置: 首页 > 工具软件 > Fast-ismartx > 使用案例 >

git报错:[rejected]master->master(non-fast-forward)

周越泽
2023-12-01

! [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文件

之后再次提交,还是报这个错,再次百度,最后执行下面这条命令,意思是可以允许不相关历史提交,强制合并。

$git pull origin master --allow-unrelated-histories

最后成功提交。

 类似资料: