当我们在本地有个项目,想要和远程建立关联并推送到远程仓库的时候,有时会提示fatal: refusing to merge unrelated histories。原因是因为两个仓库不同,无效进行pu
当我们在本地有个项目,想要和远程建立关联并推送到远程仓库的时候,有时会提示fatal: refusing to merge unrelated histories。原因是因为两个仓库不同,无效进行pull操作。下面介绍下出现此情况的场景:
我在Github新建一个仓库,写了License,然后把本地一个写了很久仓库上传。
git pullfatal: refusing to merge unrelated histories
先pull,因为两个仓库不同,发现refusing to merge unrelated histories
,无法pull
因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在git pull
,这句代码是在git 2.9.2版本发生的,最新的版本需要添加--allow-unrelated-histories
假如我们的源是origin,分支是master,那么我们 需要这样写git pull origin master ----allow-unrelated-histories
需要知道,我们的源可以是本地的路径