Git报错-refusing to merge unrelated histories

时间:2023-03-10 01:13:36
Git报错-refusing to merge unrelated histories

执行git pull 时报错:

出现这个问题的最主要原因还是在于本地仓库和远程仓库实际上是独立的两个仓库。假如我之前是直接clone的方式在本地建立起远程github仓库的克隆本地仓库就不会有这问题了。

可以在pull命令后紧接着使用--allow-unrelated-history选项来解决问题(该选项可以合并两个独立启动仓库的历史)。

命令:

$git pull origin master –allow-unrelated-histories

以上是将远程仓库的文件拉取到本地仓库了。