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
Discussions

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
Obsidian Git: 'Pull failed (merge): failed: refusing to merge unrelated histories.'
Hi all, I hope you’re well, ‘Pull failed (merge): failed: refusing to merge unrelated histories.’ I’m trying to figure out this problem that’s started happening. I believe this may be because I’m using Obsidian Sync with iCloud and Obsidian Git. I’ve read that one workaround may ... More on forum.obsidian.md
🌐 forum.obsidian.md
2
0
February 18, 2024
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
A collaborator on my github repo is unable to merge his changes to the main branch.
Basically, it means the person getting the unrelated histories did a git init instead of a git clone. Only the first person can do a git init. Everyone after that needs to clone. More on reddit.com
🌐 r/AskProgramming
4
2
April 28, 2021
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 ...
🌐
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....
🌐
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....
🌐
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
🌐
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 - Ensure the branches you’re merging or rebasing are related to your project. The “fatal: refusing to merge unrelated histories” error happens when you try to merge or rebase branches that have no common commit history.
🌐
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"
Use the --allow-unrelated-histories flag when merging their branches. ... If you have a new local repository and want to pull changes from an existing remote repository, use the --allow-unrelated-histories flag during the pull operation: ... ...
🌐
Obsidian
forum.obsidian.md › help
Obsidian Git: 'Pull failed (merge): failed: refusing to merge unrelated histories.' - Help - Obsidian Forum
February 18, 2024 - Hi all, I hope you’re well, ‘Pull failed (merge): failed: refusing to merge unrelated histories.’ I’m trying to figure out this problem that’s started happening. I believe this may be because I’m using Obsidian Sync with iCloud and Obsidian Git. I’ve read that one workaround may be to use: git pull origin master --allow-unrelated-histories Does anyone know how I can enter these type of commands into Obsidian?
🌐
Medium
bryantson.medium.com › how-to-fix-fatal-refusing-to-merge-unrelated-histories-in-git-738ce02e50e3
How to fix “fatal: refusing to merge unrelated histories” in git | by Bryant Jimin Son | Medium
April 13, 2023 - This error occurred because the merge becomes incompatible due to two histories (one in new GitHub repository and one that I cloned) are different. The easiest way to solve is by passing--allow-unrelated-histories option in git pull.
🌐
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.
🌐
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.
🌐
DZone
dzone.com › testing, deployment, and maintenance › deployment › can you avoid the git ‘fatal: refusing to merge unrelated histories’ error?
Can You Avoid the Git 'Fatal: Refusing to Merge Unrelated ...
August 19, 2022 - The "fatal: refusing to merge unrelated histories" error has two possible solutions: short and long. The shorter solution entails the granting of permission to merge unrelated histories.
🌐
Tistory
jobc.tistory.com › 177
git push, pull (fatal: refusing to merge unrelated histories) 에러
January 14, 2018 - -- fatal: refusing to merge unrelated histories · 에러 내용은 원격 저장소의 master 브랜치에서 로컬 저장소의 FETCH_HEAD를 merge하는 것이 거부되었다. commit 히스토리가 서로 관련이 없다는 뜻이다. 즉, 서로 관련성이 없기 때문에 merge할 ...
🌐
Sentry
sentry.io › sentry answers › git › merge branches with unrelated histories in git
Merge branches with unrelated histories in Git | Sentry
July 15, 2023 - Reclone the remote version of the ... If we are attempting to combine two separate codebases, we must pass the flag --allow-unrelated-histories to git merge:...
🌐
Scott Spence
scottspence.com › home › posts › git ` — allow-unrelated-histories`
Git ` — allow-unrelated-histories` - Scott Spence
June 30, 2017 - Bit misleading there as there is but the commit histories are different. How do you get around it, well the first Google result was a bit sparse with the details but then I found this which was more helpful. I needed to merge the disparate branches which is now disabled by default in git but can be enabled with the –allow-unrelated-histories flag.
🌐
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).
🌐
Laracasts
laracasts.com › discuss › channels › forge › forge-fatal-refusing-to-merge-unrelated-histories
Forge, refusing to merge unrelated histories
Hi, I got this error when trying to use Deploy Now in Laravel Forge: * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories Have tried the following on the server (digitalocean), but the problem is the same: git pull origin master --allow-unrelated-histories I know what ...
🌐
Blog++
blog.marcomonteiro.net › post › git-refusing-to-merge-unrelated-histories
Blog++ | git refusing to merge unrelated histories
March 12, 2019 - $ git pull origin develop --allow-unrelated-histories · This will also work if you’re trying to merge or rebase code.
🌐
GitHub
gist.github.com › kingluddite › 7ec82fdfa3700427efa0e5b97196dea6
unrelated-histories.md · GitHub
The "unrelated histories" error usually occurs when you try to merge branches from two entirely different repositories or branches that have no common ancestor commit. If you're encountering the "Refusing to merge unrelated histories" error ...