首页 > 其他 > 详细

解决 Git 中 fatal: refusing to merge unrelated histories

时间:2021-06-16 14:43:27      阅读:18      评论:0      收藏:0      [点我收藏+]

场景

两个分支: feature/lytest。我在test分支上做了一些修改,现在需要合并到feature/ly分支。

使用命令:

Administrator@DESKTOP-H841QIF MINGW64 /g/ly_doc/glive (feature/ly)
$ git merge --squash test
fatal: refusing to merge unrelated histories

这里的问题的关键在于:fatal: refusing to merge unrelated histories.

你可能会在 git pull 或者 git push 中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?

解决方案:

在你操作命令后面加 --allow-unrelated-histories

例如:

git merge master --allow-unrelated-histories

Administrator@DESKTOP-H841QIF MINGW64 /g/ly_doc/glive (feature/ly)
$ git merge --squash test --allow-unrelated-histories
CONFLICT (add/add): Merge conflict in ...
Auto-merging ...
Squash commit -- not updating HEAD
Automatic merge failed; fix conflicts and then commit the result.

如果你是 git pull 或者 git pushfatal: refusing to merge unrelated histories
同理:
git pull origin master --allow-unrelated-histories
等等,就是这样完美的解决咯!

解决 Git 中 fatal: refusing to merge unrelated histories

原文:https://www.cnblogs.com/hnxbp/p/14888989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!