GIT Fatal : refusing to merge unrelated histories


I see:

$ git pull origin master
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

How can I avoid or get past that error message?


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:

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

Answered By – VonC

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published