Git(错误集):refusing to merge unrel
2019-09-27 本文已影响0人
CoderAPang
出现错误前进行的操作:
1、在Github上创建了一个新项目

2、本地项目目录下使用Git init创建本地仓库
git init
创建完成后可以看到出现了.git目录

3、错误:将本地项目pull到Github上
git pull https://github.com/CoderGxw/CameraAlbumTest.git

此时出现了错误提示:refusing to merge unrelated histories
原因是本地项目的git仓库和github新建立的远程项目仓库是两个独立的仓库,没有关联。
解决问题的步骤
1、添加远程仓库的关联
git remote add origin https://github.com/CoderGxw/CameraAlbumTest.git

添加完成之后,使用
git remote -v
可以查看到出现了该仓库fetch和push

2、把两个项目合并
使用命令git pull origin master --allow unrelated-histories
将两个项目合并

3、将本地项目push到GitHub上
使用git push origin master:master
将本地项目push
