git fatal: refusing to merge unrelated histories

本文介绍了在使用Git从远程仓库拉取代码时遇到的“refusing to merge unrelated histories”错误及其解决方案。通过添加特定参数,可以成功地将远程仓库的内容合并到本地不同名的文件夹中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在拉取远程仓库上的项目时出现了这个个问题

C:\Users\Administrator\Source\Repos\NewRepo>git pull https://github.com/houchuanhao/ACM.git master
From https://github.com/houchuanhao/ACM

错误提示如下

 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

原因是在本地的文件夹为NewRepo,与远程仓库名称不一样

解决方案:

pull时添加 –allow-unrelated-histories

C:\Users\Administrator\Source\Repos\NewRepo>git pull origin master --allow-unrelated-histories
From github.com:houchuanhao/ACM
 * branch            master     -> FETCH_HEAD
Merge made by the 'recursive' strategy.
 README.md | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 README.md
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值