zzg@DESKTOP-V6U402I MINGW64 /c/sjwt_workspace/supermarker (main)
$ git pull origin main
From https://github.com/zhouzhiwengang/supermarker
* branch main -> FETCH_HEAD
fatal: refusing to merge unrelated histories
问题的关键在于:fatal: refusing to merge unrelated histories
你可能会在git pull
或者git push
中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?
解决办法:
在你操作命令后面加--allow-unrelated-histories
比如:
git pull origin main --allow-unrelated-histories
zzg@DESKTOP-V6U402I MINGW64 /c/sjwt_workspace/supermarker (main)
$ git pull origin main --allow-unrelated-histories
From https://github.com/zhouzhiwengang/supermarker
* branch main -> FETCH_HEAD
Merge made by the 'recursive' strategy.
README.md | 1 +
1 file changed, 1 insertion(+)
create mode 100644 README.md
如果你是git push
报fatal: refusing to merge unrelated histories
同理:git push origin main --allow-unrelated-histories