Jerry.Shad Jerry.Shad - 26 days ago 21
Git Question

How to fix "refusing to merge unrelated histories" when uploading project to github?

I have installed Github desktop and git on windows machine, I got a github account and created a dummy repository.

When I intend to upload my package through git bash command line, it fails with error:

fatal: refusing to merge unrelated histories


Here is the screenshot of what I did:

enter image description here

I used several ways to overcome this issues by using existing solution from this community, but still didn't fix the problem. Does anyone know any trick of working this problem? How can I upload my projects to github successfully?

Answer

Try the following:

cd /path/to/my/repo
rm -rf .git
git init
git add --all
git commit -m "Initial commit"
git remote add origin <remote repo URL>
git push -u origin master

Be sure to replace /path/to/my/repo with path to your repo directory(e.g. C:\Users\jvrat\Documents\MSPC), and <remote repo URL> with URL to your remote repo (e.g. https://github.com/username/repo_name.git).

Comments