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
🌐
Medium
spences10.medium.com › git-allow-unrelated-histories-a39a3814b981
Git ` — allow-unrelated-histories` | by Scott Spence | Medium
September 30, 2020 - Git ` — allow-unrelated-histories` How to combine two separate unrelated Git repositories into one with single history timeline. Just adding a quick note on this… I had a project that started off …
Discussions

Ability to make pull --allow-unrelated-histories
Currently, if we want to work with some pull request with GitPython, it is not possible afaik to allow unrelated histories. The default behavior has changed since git 2.9: "git merge" use... More on github.com
🌐 github.com
2
December 20, 2016
Fix fatal: refusing to merge unrelated histories on git pull
Body I’m getting fatal: refusing to merge unrelated histories when I run git pull on a repo I just initialized locally and connected to an existing GitHub repo. How do I fix this safely? Guidelines... More on github.com
🌐 github.com
3
2
January 2, 2026
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
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
🌐
DEV Community
dev.to › donovanrichardson › adding-a-new-remote-and-merging-unrelated-branches-1mkm
Adding a New Remote and Merging Unrelated Branches - DEV Community
August 24, 2020 - 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.
🌐
Git
git-scm.com › docs › git-merge
Git - git-merge Documentation
--allow-unrelated-histories · By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no ...
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-merge-unrelated-histories-in-git
How to Merge Unrelated Histories in Git? - GeeksforGeeks
July 23, 2025 - Merging unrelated histories in Git is a straightforward process when you know the right steps. By using the --allow-unrelated-histories flag, you can combine projects or branches with different histories, enabling better project management and ...
Find elsewhere
🌐
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 can be resolved by using the --allow-unrelated-histories flag with the git rebase or git merge commands. Alternatively, you can perform a manual merge to integrate the changes.
🌐
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"
Attempt to merge the remote branch (e.g., main) into your local branch (e.g., main) using the --allow-unrelated-histories flag: ... This command tells Git to permit the merge despite the lack of shared history between the branches.
🌐
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 - # Fetch the remote git fetch origin # Merge allowing unrelated histories git merge origin/main --allow-unrelated-histories # If no file name conflicts, merge completes automatically # Both sets of files now exist in your repo
🌐
Tech Blog
knz.hashnode.dev › using-the-allow-unrelated-histories-flag
Merge with --allow-unrelated-histories flag - Tech Blog
September 13, 2024 - Merge the branches, allowing unrelated histories: git merge --allow-unrelated-histories <repo-name>/<branch-name>
🌐
Career Karma
careerkarma.com › blog › git › how to solve fatal: refusing to merge unrelated histories
How to Solve fatal: refusing to merge unrelated histories | Career Karma
December 1, 2023 - The fatal: refusing to merge unrelated histories git error can be resolved using the --allow-unrelated-histories flag. On Career Karma, learn how to resolve this common error.
🌐
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 - Yes, you can use `--allow-unrelated-histories` with `git pull` to fetch and merge changes from a remote repository with a different commit history.
🌐
Baeldung
baeldung.com › home › git › how to fix git “refusing to merge unrelated histories”
How to Fix Git “Refusing to Merge Unrelated Histories” | Baeldung on Ops
February 6, 2024 - The –allow-unrelated-histories option will tell the Git that we allow merging branches with no common history base, which then should finish the merge without errors. We should note that for the Git version 2.9 or older, this option is not ...
🌐
GitHub
github.com › gitpython-developers › GitPython › issues › 560
Ability to make pull --allow-unrelated-histories · Issue #560 · gitpython-developers/GitPython
December 20, 2016 - Currently, if we want to work with some pull request with GitPython, it is not possible afaik to allow unrelated histories. The default behavior has changed since git 2.9: "git merge" used to allow merging two branches that have no commo...
Author   gitpython-developers
🌐
GitHub
gist.github.com › kingluddite › 7ec82fdfa3700427efa0e5b97196dea6
unrelated-histories.md · GitHub
Git is essentially saying that it cannot create a meaningful merge with no common base. To proceed with merging unrelated histories, you can use the --allow-unrelated-histories ...
🌐
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 - To resolve this issue, you need to explicitly tell Git that you want to merge these unrelated histories. You can do this by using the --allow-unrelated-histories option with the git merge or git pull command.
🌐
CICube
cicube.io › blog › refusing-to-merge-unrelated-histories
What is refusing to merge unrelated histories Error? | CICube
December 10, 2024 - If you don't have time to read the full article, here are the quick solutions to resolve the error: ... –allow-unrelated-histories: Attach this flag to your merge command when you want to merge unrelated histories: