git push 码云项目时报错! [rejected]

2020-12-03  本文已影响0人  吃肉肉不吃肉肉

git切换远程分支后,想要push到另一个远程仓库,执行 git push origin master后此时报错:

To gitee.com:***
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:***'
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.

在网上搜了好久,输入了各种无效和错误的命令后,终于找到了解决办法:
1、git pull origin master --allow-unrelated-histories //把远程仓库和本地同步,消除差异

2、重新add和commit相应文件

3、git push origin master

4、此时就能够上传成功了

上一篇 下一篇

猜你喜欢

热点阅读