Ali Boukeroui 1 min read
"The Fatal: Refusing To Merge Unrelated Histories" Git Error
Git's "fatal": refusal to combine unrelated histories "error occurs when two unrelated projects are merged (i.e., projects that do not know each other and have a different commit history).
Consider the following two scenarios:
- You cloned the project and, somehow, the .git directory has been removed or corrupted. This leads to Git not knowing about your local history and, therefore, will cause it to throw this error when you try to push to or pull from the remote repository.
- You have created a new repository, added a few commits to it, and now you are trying to pull a remote repository that already has some commits of its own. Git will throw an error in this case, because it has no idea how these projects are related.
The Solution To Fix The Fatal: Refusing To Merge Unrelated Histories Git Error :
The error is fixed by toggling the allow-unrelated-histories switch. After a git pull
or git merge
command, add the following tag:
git pull origin master --allow-unrelated-histories