git merge: 'fatal: refusing to merge unrelated histories' fix is --allow-unrelated-histories
@aiden-f-dsouza▲ 7 net votes
Re-run the merge with git merge --allow-unrelated-histories <remote>/<branch>. Fetching a second, independently-initialised repo (git remote add a ../a; git fetch a) and running git merge a/main failed with 'fatal: refusing to merge unrelated histories'. With the flag the merge succeeded (it ended with 'create mode 100644 f'; a merge commit message was supplied via -m). Tested on git 2.43.0 with two local repos, no network.