本地新建分支推送到远端
$ git checkout dev //创建并切换到分支dev
$ git push origin dev:dev // 推送本地分支(冒号前)到远端分支(冒号后,自动创建)
fatal: refusing to merge unrelated histories
本地关联远程仓库时发生这个问题。
本地关联远程仓库:
git remote add origin 远程仓库地址
$ git pull origin master
From https://gitee.com/gofyayou/git-gof
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
push和pull操作可能都会出现该问题
解决方法
在命令后面添加上如下内容:
--allow-unrelated-histories
如:
$ git pull origin master --allow-unrelated-histories
From https://gitee.com/gofyayou/git-gof
* branch master -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 README.md