Git出现 [rejected] master -> master (fetch first) error: failed to push some refs to解决方法

欧阳英彦
2023-12-01

在git add以及commit之后
通过push的时候
出现如下问题

PS D:\项目\manongyanjiuseng> git push origin master
To ssh://xx.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'ssh://xx.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.

主要的原因是push上去的时候,仓库内容和本地内容已经不一样了

所以直接拉取最新的下来更改替换即可
通过这条命令:git pull --rebase origin master
然后再git push origin master

 类似资料: