How to deal with "refusing to merge unrelated histories" error

I ended in the same situation after a series of mishapps. Have a look at this thread : I just did a 

git pull --allow-unrelated-histories

and it was fixed!

1268 Likes

 I was also facing the same problem. But I realised I was trying to push my one git project material on other remote git project. Solution:

Clone the fresh project again and this time make sure cloning link is starting from ssh if you have added the SSH key and https:// if you have added the puttyKey.

2 Likes

Thanks, worked fine for me.

20 Likes

I am in a similar situation where I am getting the same messages. Probably I just need to do the

--allow-unrelated-histories

But I wish I knew what situations where I should not. Obviously we get the message because there might sometimes be a good reason to not do the allow. I got into my situation because I did not know what I was doing and did something I should not have.

31 Likes

I am receiving the message saying “there is no tracking information for the current branch”

5 Likes

Help for me. thanks!

1 Like

Thank, you for you help.

git pull --allow-unrelated-histories

worked

3 Likes

This is great, thank you very much!

http://gph.is/1U7OwpV

1 Like

This command is a dangerous one. “git pull --allow-unrelated-histories” it has messed up my whole codebase i dont know what happened and am not in a position to recover from it

2 Likes

It’s worked for me.
Very thanks! i have solved my problem

4 Likes

Thanks, It works for me.

Works for me too ! thank you :slight_smile:

Thanks, Woked superbly for me as well.
but little more specific:

git pull <remote> <branch> --allow-unrelated-histories

4 Likes

Worked like a charm

I got this error, but found another cause:

somehow, the ssh url of another project got into this one’s .git/config file.

So before running this to accept ‘unrelated histories’, you may want to confirm you have the right repo’s url.

I fixed mine and it started working again.  :slight_smile:

1 Like

Probably because you did a git init on something like “the same” set of files locally, then tried to merge with the files on the repository. The better way is to clone from the repository, then work from that.

3 Likes

I tried the --allow-unrelated-histories and got this:

warning: Cannot merge binary files: biostats.final.3.2.pdf (HEAD vs. 93379526ed908abd4f58b2010eb055aace5df522)

warning: Cannot merge binary files: .DS_Store (HEAD vs. 93379526ed908abd4f58b2010eb055aace5df522)

Auto-merging <file name here>

CONFLICT (add/add): Merge conflict in <file name here>

Auto-merging <file name here>

CONFLICT (add/add): Merge conflict in  <file name here>

Auto-merging  <file name here>

CONFLICT (add/add): Merge conflict in  <file name here>

Auto-merging  <file name here>

CONFLICT (add/add): Merge conflict in  <file name here>

Auto-merging  <file name here>

Automatic merge failed; fix conflicts and then commit the result.

Worked for me. Thank you and God Bless! :slight_smile:

This comment should be deleted or at least not appear as first, See the accepted answer.

75 Likes