Solution to Fatal: Refusing to Merge Unrelated Histories
Contents
Reason
When i initialize the github repository first, and push my code to it, there often occur this error:
git pull origin master
fatal: refusing to merge unrelated histories
This is because git judges that two unrelated projects are merged (i.e., projects that are not aware of each other’s existence and have mismatching commit histories).
Solution
This error can be solved by toggling the allow-unrelated-histories switch. You can use this code below:
git pull origin master --allow-unrelated-histories