GIT Fatal : refusing to merge unrelated histories

让人想犯罪 __ 提交于 2019-12-03 19:07:21

问题


I see:

$ git pull origin master
From https://bitbucket.org/tecgenome/chl-v2.0-html
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

How can I avoid or get past that error message?


回答1:


Since Git 2.9 (April 2016), you can try:

git pull --allow-unrelated-histories origin master

But check why those branches are no longer common though.
May be there was a force push rewritting all the history of origin/master.

In which case, if you don't have local commits of your own, it is best to reset your branch to the new one:

git fetch
git reset --hard origin/master



回答2:


I did meet the same issue, and try the command it gets work.

git merge abbranch --allow-unrelated-histories

here we assume that abbranch is unrelated to current branch. Above command merge abbranch to current branch.




回答3:


if you are facing push Recjected or this issue in android studio you just open your project enable version control integration

and Move to project from android. right click on package --> go to Git --> Add

now come on downside click on terminal and follow given below step

 git remote add origin <repository url>

    git clone <repository url>
    git pull origin master --allow-unrelated-histories
    git merge origin origin/master
    ... add and commit here...
    git push origin master


来源:https://stackoverflow.com/questions/40036648/git-fatal-refusing-to-merge-unrelated-histories

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!