'fatal: refusing to merge unrelated histories' in git
This nasty error in git happens, when you try to merge wo repositories, that are not aware of the existence of the other repository. This means, these repositories have a mismatching commit history.
This error can happen in the following situations:
- After you created a new repository and added some commits locally, you try to pull from a remote repository, which already has some commits on its own. In this case git has no clue, these twi repositories might be related, so it throws the error.
- If the
.gitfolder inside a cloned repository git deleted or corrupted, git becomes unaware of the local history and will complain with this error message, when you try to
pullfrom the remote repository.
git pull and the
git push offer a command line option named allow-unrelated-histories.
git pull origin master --allow-unrelated-histories