Git 合并时提示 refusing to merge unrelated histories

如果我们在 Git 中将 2 个不同的仓库进行合并的时候,可能会遇到提示。

fatal: refusing to merge unrelated histories

如下图在 IDEA 中的提示。

2022-10-24_13-28-04

解决办法

需要在合并操作后添加参数

--allow-unrelated-histories

如我们使用下面的命令:

git -c credential.helper= -c core.quotepath=false -c log.showSignature=false merge origin/kiler/main_ui --no-stat -v --allow-unrelated-histories

当我们完成上面的命令的话, 2 个不同的分支将会进行合并。