当前位置:   article > 正文

git pull报错:fatal: refusing to merge unrelated histories_git pull fatal: refusing to merge unrelated histor

git pull fatal: refusing to merge unrelated histories

问题重现:

在使用git pull命令拉代码时,控制台一直报如下错误:

fatal: refusing to merge unrelated histories

翻译一下就是:

拒绝合并不相关的历史

原因:

基于同一个origin,做了两次完全不同的提交。

一次提交是在github上直接创建文件并commit,

第二次是在本地还没有拉新代码的情况下修改了代码,并进行pull -> commit 和push

解决方法:

输入如下命令:

git pull --allow-unrelated-histories

即允许合并不相关历史的内容。

至此,git pull成功。

  1. Merge made by the 'recursive' strategy.
  2. .gitignore/.gitignore | 1 +
  3. db.json | 20 ++++++++++++++++++++
  4. 2 files changed, 21 insertions(+)
  5. create mode 100644 .gitignore/.gitignore
  6. create mode 100644 db.json

 

参考文章: 
1. 使用git pull提示refusing to merge unrelated histories 
2. git无法pull仓库refusing to merge unrelated histories

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/826072?site
推荐阅读
相关标签
  

闽ICP备14008679号