Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git refusing to merge unrelated histories. What is 'unrelated histories'?

Tags:

git

In my local, I made new text file -> git add newfile.txt -> commit -> pull origin master -> ERROR!

"refusing to merge unrelated histories".

What is unrelated histories? , what is related histories?

like image 606
Byeongin Yoon Avatar asked Jul 24 '17 04:07

Byeongin Yoon


People also ask

What is unrelated histories in git?

The “fatal: refusing to merge unrelated histories” Git error occurs when two unrelated projects are merged (i.e., projects that are not aware of each other's existence and have mismatching commit histories). Consider the following two cases that throw this error: You have cloned a project and, somehow, the .

How do I fix unrelated branches in git?

But this doesn't mean that Git cannot perform any merge. In fact, all you need to do to merge unrelated branches is to use the flag --allow-unrelated-histories . This tells Git to combine all the files and commits of both unrelated branches into one branch, as long as there are no file conflicts.

How do you stop git from merging?

You can use the git reset --merge command. You can also use the git merge --abort command.

What does git merge do?

Merging is Git's way of putting a forked history back together again. The git merge command lets you take the independent lines of development created by git branch and integrate them into a single branch.


1 Answers

I think you have commit in remote repository and when you pull this error happen.

use this command

git pull origin master --allow-unrelated-histories git merge origin origin/master 
like image 59
Yashar Panahi Avatar answered Oct 17 '22 02:10

Yashar Panahi