致命:在添加 git remote 后拒绝合并不相关的历史记录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50111060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:16:16 来源:igfitidea点击:
fatal: refusing to merge unrelated histories after adding git remote
提问by ramab01
I've added a remote repository to the folder where I am working with :
我已将远程存储库添加到我正在使用的文件夹中:
git remote add origin https://github.com/<username>/<repo>.git
If I type:
如果我输入:
git pull origin master
I get:
我得到:
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
But I get:
但我得到:
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
回答by Fernando Espinosa
You need to either reset
or commit
your changes first:
您首先需要reset
或commit
您的更改:
git reset --hard
or:
或者:
git commit -m "saving changes..."
Then you can do:
然后你可以这样做:
git pull origin master --allow-unrelated-histories