GIT Fatal : refusing to merge unrelated histories

2019-02-06 22:27发布

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?

标签: git bitbucket
3条回答
做个烂人
2楼-- · 2019-02-06 23:05

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楼-- · 2019-02-06 23:10

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
查看更多
祖国的老花朵
4楼-- · 2019-02-06 23:24

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
查看更多
登录 后发表回答