解决Git中fatal: refusing to merge unrelated histories

2019-05-29 14:19:19

Git的报错

在使用Git的过程中有时会出现一些问题,那么在解决了每个问题的时候,都需要去总结记录下来,下次不再犯。

一、fatal: refusing to merge unrelated histories

今天在使用Git创建项目的时候,在两个分支合并的时候,出现了下面的这个错误。

~/SpringSpace/newframe on  master ⌚ 11:35:56$ git merge origin/druid
fatal: refusing to merge unrelated histories

这里的问题的关键在于:fatal: refusing to merge unrelated histories 
你可能会在git pull或者git push中都有可能会遇到,这是因为两个分支没有取得关系。那么怎么解决呢?

二、解决方案

在你操作命令后面加--allow-unrelated-histories 
例如: 
git merge master --allow-unrelated-histories

~/SpringSpace/newframe on  druid ⌚ 11:36:49$ git merge master --allow-unrelated-historiesAuto-merging .gitignore
CONFLICT (add/add): Merge conflict in .gitignoreAutomatic merge failed; fix conflicts and then commit the result.

如果你是git pull或者git pushfatal: refusing to merge unrelated histories 
同理: 
git pull origin master --allow-unrelated-histories 
等等,就是这样完美的解决咯!


  • 2020-02-06 13:32:10

    android.os.NetworkOnMainThreadException

    在Android 4.0以上,网络连接不能放在主线程上,不然就会报错android.os.NetworkOnMainThreadException。但是4.0下版本可以不会报错。

  • 2020-02-07 23:46:44

    You must call removeView() on the child's parent first解决办法

    出现这样的情况最多是发生在recyclerView中,holder复用的过程中,多次添加view,第一次添加的时候view有了父类了,可能就是复用引起的。 我是发生在给recyclerView添加广告view的时候发生的。

  • 2020-02-11 17:43:35

    基于VCamera,仿微信录制短视频

    vcamera.so这个确实挺好用,可定制性也挺高,但是确定也不小,需要引入的这个so包,10M啊。对于安装包苛刻的用户,这是致命啊。 我现在是抛弃他了。但是在这里还是记录一下用法吧。防止以后再用他。

  • 2020-02-13 13:37:53

    mysql随机排序

    首页热门栏目需要随机显示几条信息