Skip to content
Home » How to allow git to merge unrelated histories

How to allow git to merge unrelated histories

Let’s start the discussion about How to allow git to merge unrelated histories in following methods.

One solution is to use the –allow-unrelated-histories git flag. In this case, the git command will look like this: –allow-unrelated-histories git pull origin master You can substitute origin with the remote repository you are pulling from.

fatal: refusing to merge unrelated histories

The git command in this case will be something like this: git pull origin master —allow-unrelated-histories.

You can replace origin with the remote repository from which you are pulling. You can also replace the master branch with the branch into which you wish the pull request to integrate.

The rationale behind —allow-unrelated-histories is that git allows you to merge branches that aren’t related. When there are no file conflicts, this git flag works well.

Run the below command as per requirement.

git pull origin master --allow-unrelated-histories
git pull origin branchname --allow-unrelated-histories
git pull origin main --allow-unrelated-histories

I hope the strategies listed above work for you. Happy coding and come back again.

Similar Post : Git refuses to merge unrelated histories