DEBUG.WIKI
PanstarCloud:部署应用,接入 AI,云服务器与 AI 网关
晚安云;香港 CN2 ¥15/月
V.PS:让项目靠近用户,亚太、欧洲、北美 KVM VPS

解决 Git 报错 fatal: refusing to merge unrelated histories 拉取失败

分析 Git pull 首次拉取已有代码的远程分支报 unrelated histories 根因,提供 --allow-unrelated-histories 步骤。

问题现象

fatal: refusing to merge unrelated histories

触发根因

本地与远程仓库在初始化时各自生成了独立的初始 commit。

解决步骤与操作命令

步骤一:强制允许合流

git pull origin main --allow-unrelated-histories
git push origin main

历史对齐完成。