When you try to pull a remote branch to a local with two unrelated histories or merge two branches with unrelated hisotories, you will encounter this error.
$ git pull
fatal: refusing to merge unrelated histories
This issue can be resolved in 2 ways:
We can accept and have both branch histories by using the argument --allow-unrelated-histories Note: If you habe the same file name with changes, it will result in conflicts and these are supposed to be resolved manually
$ git pull --allow-unrelated-histories
Merge made by the 'recursive' strategy.
$ git checkout branchA
$ git merge branchB --allow-unrelated-histories
Merge made by the 'recursive' strategy.
Note: This will override the changes present in the remote.
$ git push --force
$ git checkout branchA
$ git merge branchB -X ours || die "complex merge conflict"
$ git checkout branchA
$ git merge branchB -X theirs || die "complex merge conflict"