(已解决)master提交项目到远程仓库出现There isn’t anything to compare. main and master are entirely different ...”

一、问题

在GitHub pull requests时出现There isn’t anything to compare. main and master are entirely different commit histories.
在这里插入图片描述

二、分析及解决

这是由于提交的分支与原有main完全不同导致系统不允许合并。
可能非最优但有用

# 切换分支至master
git checkout master
# 强制重命名master分支为main分支
git branch main master -f
# 切换分支至main
git checkout main
# 强制推送本地main分支至远程库,并覆盖远程main分支内容
git push origin main -f

参考:http://t.csdn.cn/UgRPC

猜你喜欢

转载自blog.csdn.net/yolo_______95/article/details/128460256