问题
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