You can use --allow-unrelated-histories to force the merge to happen.

The reason behind this is that default behavior has changed since Git 2.9:

"git merge" used to allow merging two branches that have no common base by default, which led to a brand new history of an existing project created and then get pulled by an unsuspecting maintainer, which allowed an unnecessary parallel history merged into the existing project. The command has been taught not to allow this by default, with an escape hatch --allow-unrelated-histories option to be used in a rare event that merges histories of two projects that started their lives independently.

See the Git release changelog for more information.

More information can be found in this answer.

Answer from blue112 on Stack Overflow
🌐
GitHub
github.com › saleor › storefront › issues › 326
fatal: refusing to merge unrelated histories · Issue #326 · saleor/storefront
August 1, 2022 - On July 29th we've merged react-storefront and saleor-checkout repositories into a single monorepo. If you've forked this repo previosly, when merging with the main branch you might get an unexpected error message: fatal: refusing to merge unrelated histories.
Author   saleor
Discussions

How to deal with "refusing to merge unrelated histories" error
Short version of my question : For years, I have been using a simple, single one-branch, one-contributor public online Github repo. A few days ago my computer died suddenly and I bought a new one. ... More on github.com
🌐 github.com
19
104
What is The “fatal: refusing to merge unrelated histories” Git error?
Use in Appropriate Context: Typically, merging unrelated histories is not a regular practice and might indicate an issue with how branches or repositories are managed. It’s appropriate in specific cases like consolidating two independent projects into a single repository. Understanding and resolving the "fatal: refusing ... More on designgurus.io
🌐 designgurus.io
1
10
June 25, 2024
How am I supposed to merge these two? when I try to git merge master, I get told "refusing to merge unrelated histories"
The —allow-unrelated-histories param might do the job. See this for more detailed explanation More on reddit.com
🌐 r/gitlab
20
5
March 11, 2022
Merging unrelated histories
Since you changed the original commit with your ament, it makes sense to force push now, as you wanted to change the original commit. git push --force-with-lease More on reddit.com
🌐 r/git
12
6
November 21, 2020
People also ask

What happens if I merge unrelated histories?
Merging unrelated histories can result in a confusing commit graph. Ensure the branches you're merging are related to your project.
🌐
blog.openreplay.com
blog.openreplay.com › openreplay blog › how to fix 'fatal: refusing to merge unrelated histories' during git rebase
How to Fix 'fatal: refusing to merge unrelated histories' During ...
How can I prevent 'fatal: refusing to merge unrelated histories' errors?
Ensure your branches share a common commit history. When working with forks or split repositories, establish a common ancestor or use patch files to apply changes instead of directly merging or rebasing.
🌐
blog.openreplay.com
blog.openreplay.com › openreplay blog › how to fix 'fatal: refusing to merge unrelated histories' during git rebase
How to Fix 'fatal: refusing to merge unrelated histories' During ...
How to Fix "fatal: refusing to merge unrelated histories" in Git
This error appears when you try to merge two Git repositories that share no common ancestor — their histories are completely unrelated from Git's perspective. A common trigger is creating a new repository on GitHub with an auto-generated README or LICENSE file and then trying to push a separate, pre-existing local repository to it. To resolve it, run git pull origin main --allow-unrelated-histories, which tells Git to proceed with the merge despite the lack of a shared ancestor. Git will then attempt to combine the two histories, potentially surfacing conflicts if both sides contain files with
🌐
git-tower.com
git-tower.com › learn › git faq › how to fix "fatal: refusing to merge unrelated histories" in git
How to Fix "fatal: refusing to merge unrelated histories" in Git ...
🌐
DEV Community
dev.to › werliton › git-error-fatal-refusing-to-merge-unrelated-histories-2287
Git Error: `fatal: refusing to merge unrelated histories` - DEV Community
May 23, 2025 - You're trying to merge two completely separate repositories. Use the --allow-unrelated-histories flag to force Git to merge:
🌐
Chip Cullen
chipcullen.com › resolving-github-repo-and-create-react-app
Resolving a github repo and a new Create React App: Chip Cullen
I run npx create-react-app my-apps-name locally but that makes a new directory all unto itself · What to do? Oh, yeah, add a new remote git remote add origin https://github.com/user/repo.git · git pull origin master .... well, crap. fatal: refusing to merge unrelated histories ·
🌐
Reactgo
reactgo.com › home › how to merge unrelated histories in git
How to merge unrelated histories in Git | Reactgo
February 25, 2023 - If we are trying to merge two different ... to merge unrelated histories”, it means the merge histories of two projects are not related to each other because of mismatching the commits....
🌐
DEV Community
dev.to › abisaifredrick › fatal-refusing-to-merge-unrelated-histories-3bb4
fatal: refusing to merge unrelated histories - DEV Community
August 12, 2024 - Create a new empty commit that connects unrelated branches then merge those branches. ... When setting up a new repository, it’s advisable to initialize it using an existing project. This approach links their histories, helping to prevent the issue of unrelated histories.
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-fix-git-refusing-to-merge-unrelated-histories
How to Fix Git “Refusing to Merge Unrelated Histories”? - GeeksforGeeks
July 23, 2025 - When two repositories or branches do not share any commits, Git treats them as having unrelated histories and refuses to merge them by default to prevent potential conflicts and confusion.
🌐
Git Tower
git-tower.com › learn › git faq › how to fix "fatal: refusing to merge unrelated histories" in git
How to Fix "fatal: refusing to merge unrelated histories" in Git | Learn Version Control with Git
1 day ago - It is good practice to first ... so, the solution is simple. To fix the error, you can use the --allow-unrelated-histories option when running the git merge command....
🌐
OneUptime
oneuptime.com › home › blog › how to fix 'fatal: refusing to merge unrelated histories'
How to Fix 'Fatal: refusing to merge unrelated histories'
January 24, 2026 - # Pull with unrelated histories ... --abort · The "refusing to merge unrelated histories" error protects you from accidentally combining separate projects....
🌐
OpenReplay
blog.openreplay.com › openreplay blog › how to fix 'fatal: refusing to merge unrelated histories' during git rebase
How to Fix 'fatal: refusing to merge unrelated histories' During Git Rebase
December 2, 2024 - To resolve the error, use the --allow-unrelated-histories flag cautiously. Alternatives include manually connecting histories or using patch files. Ensure the branches you’re merging or rebasing are related to your project.
🌐
Educative
educative.io › answers › the-fatal-refusing-to-merge-unrelated-histories-git-error
The “fatal: refusing to merge unrelated histories” Git error
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).
🌐
Graphite
graphite.com › guides › how-to-resolve-git-error-refusing-to-merge-unrelated-histories
How to resolve the Git error "refusing to merge unrelated histories"
To resolve the refusing to merge unrelated histories error, you need to instruct Git to allow merging of unrelated histories.
🌐
DEV Community
dev.to › wlarch › git-error-fatal-refusing-to-merge-unrelated-histories-explanation-3f90
Git error “fatal: refusing to merge unrelated histories” explanation - DEV Community
January 25, 2021 - You can solve this issue by adding the allow-unrelated-histories flag. After executing git pull or git merge, add the following flag:
🌐
Moon Technolabs
moontechnolabs.com › qanda › refusing-to-merge-unrelated-histories
Fixing “Refusing to Merge Unrelated Histories” in Git
March 26, 2025 - To bypass this error and merge the branches, use the –allow-unrelated-historiesflag:
🌐
DEV Community
dev.to › omesha › solving-the-error-fatal-refusing-to-merge-unrelated-histories-491h
Solving the Error - "fatal: refusing to merge unrelated histories" - DEV Community
July 20, 2025 - Git was not able to find the shared base to apply and combine changes. So, it refused to merge by default as a safety measure, by throwing an Error. As I really wanted to combine these repositories, I used a git command to allow the merge with a git option --allow-unrelated-histories
🌐
Komodor
komodor.com › home › articles › how to fix ‘fatal: refusing to merge unrelated histories’ git error
How to fix 'fatal: refusing to merge unrelated histories' Git error
September 15, 2025 - The alternative (and longer) way of fixing the fatal: refusing to merge unrelated histories issues is to unstage your current commits, stash them, clone your required remote repository, and then place your stashed branch contents into the new clone.
🌐
Medium
sahilali.medium.com › understanding-and-resolving-fatal-refusing-to-merge-unrelated-histories-in-git-8701d07624c5
Understanding and Resolving “fatal: refusing to merge unrelated histories” in Git | by Sahil Ali | Medium
September 30, 2023 - In other words, Git believes that the branches are unrelated, and merging them could potentially mix unrelated codebases, leading to chaos. Imagine you have two branches: branchA and branchB. If there is no shared commit or common ancestor between these branches, Git will consider their histories unrelated.
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-fix-git-refusing-to-merge-unrelated-histories-on-rebase
How to Fix - Git Refusing to Merge Unrelated Histories on Rebase? - GeeksforGeeks
May 27, 2024 - This flag can be used with both git merge and git rebase. First, ensure you have the latest changes from the remote repository. ... Use the --allow-unrelated-histories flag to rebase your branch.