致命的:添加git remote之后拒绝合并无关的历史记录 [英] fatal: refusing to merge unrelated histories after adding git remote

查看:69
本文介绍了致命的:添加git remote之后拒绝合并无关的历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在使用的文件夹中添加了一个远程存储库:

I've added a remote repository to the folder where I am working with :

git remote add origin https://github.com/<username>/<repo>.git

如果我输入:

git pull origin master

我得到:

From https://github.com/<username>/<repo>
    * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories


我也尝试过:


I have also tried:

$ git pull origin master --allow-unrelated-histories

但是我得到了

From https://github.com/...
    * branch            master     -> FETCH_HEAD
error: Your local changes to the following files would be overwritten by merge:
    <files>
Please commit your changes or stash them before you merge.
Aborting

推荐答案

您需要先resetcommit进行更改:

git reset --hard

或:

git commit -m "saving changes..."

然后您可以执行以下操作:

Then you can do:

git pull origin master --allow-unrelated-histories

这篇关于致命的:添加git remote之后拒绝合并无关的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆