How to fix unrelated histories error in git.

Cover image

Unrelated History error

What is the cause ?

This git error occurs when two unrelated projects are merged together.

Simple Illustration: You create a new repo, add a description and you check the Initialize this repository with a README option. You then go to your terminal and forget to pull before pushing, git would warn you and recommend that you git pull but then when you pull, you get this fatal: refusing to merge unrelated histories error and now you're jaded so you listen to Jaded by Drake (Yo! you see what i did there?).

How to fix it

To merge the unrelated histories, use this command

git pull --allow-unrelated-histories.

That would fix the error and you can move on with your life.

For the nerds, check here to learn more.