Reputation: 953
$ 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?
Upvotes: 40
Views: 48567
Reputation: 1324576
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.
Maybe there was a force push rewriting 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:
Warning: this will delete any untracked file, and reset your repository to origin/master
(You can try it in a copy of your current local clone)
git fetch
# Warning: RESET AHEAD
git reset --hard origin/master
Upvotes: 87
Reputation: 597
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.
Upvotes: 15
Reputation: 11
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
Upvotes: 0