Git 推送远程分支提示:refusing to merge unrelated histories
符号
阅读:706
2021-03-31 13:18:31
评论:0
zzg@DESKTOP-V6U402I MINGW64 /c/sjwt_workspace/supermarker (main)
$ git pull origin main
From https://github.com/zhouzhiwengang/supermarker
* branch main -> FETCH_HEAD
fatal: refusing to merge unrelated histories
问题的关键在于:fatal: refusing to merge unrelated histories
你可能会在git pull
或者git push
中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?
解决办法:
在你操作命令后面加--allow-unrelated-histories
比如:
git pull origin main --allow-unrelated-histories
zzg@DESKTOP-V6U402I MINGW64 /c/sjwt_workspace/supermarker (main)
$ git pull origin main --allow-unrelated-histories
From https://github.com/zhouzhiwengang/supermarker
* branch main -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 README.md
如果你是git push
报fatal: refusing to merge unrelated histories
同理:git push origin main --allow-unrelated-histories
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。