gpt4 book ai didi

git - 添加 Git 远程后 "fatal: refusing to merge unrelated histories"

转载 作者:IT王子 更新时间:2023-10-29 00:39:18 25 4
gpt4 key购买 nike

我已将远程存储库添加到我正在使用的文件夹中:

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

我也试过:

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

最佳答案

您需要先重置提交您的更改:

git reset --hard

或:

git commit -m "saving changes..."

然后你可以这样做:

git pull origin master --allow-unrelated-histories

关于git - 添加 Git 远程后 "fatal: refusing to merge unrelated histories",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50111060/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com