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
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360001797960-Error-Merging-refusing-to-merge-unrelated-histories
Error Merging - refusing to merge unrelated histories – IDEs Support (IntelliJ Platform) | JetBrains
November 29, 2018 - I've tried git cloning the project to another folder and restart Intellij with invalidate caches but I get the same issue. Any ideas? ... Looks like you are pulling from some wrong remote when doing this from IntelliJ.
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
How do I push a project from IntelliJ into an already existing repository of personal projects?
For each project, you should have a separate repository. Just to make it easy, think like a repository is like a folder. Each project should be in different folder. More on reddit.com
🌐 r/github
5
3
March 6, 2023
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
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
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360006963060-pycharm-refusing-to-merge-unrelated-histories-with-the-UI-of-merge-conflicts
pycharm refusing to merge unrelated histories with the UI of merge conflicts – IDEs Support (IntelliJ Platform) | JetBrains
January 14, 2020 - We wish to merge our different files and conflicts using the convenient pycharm merge UI, the problem is that when trying to merge we get the error " refusing to merge unrelated histories", because each of us used a different repository.
🌐
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 ...
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360000000350-Git-not-pushing-project
Git not pushing project – IDEs Support (IntelliJ Platform) | JetBrains
I even did a git fetch, git merge and I get the same errors. ... You changed the remote's URL. You pulled from the new URL with --allow-unrelated-histories ... BTW, there is no builtin git in IntelliJ, it uses a standalone git client, that is ...
🌐
JetBrains
youtrack.jetbrains.com › issue › IJPL-72863 › request-git-merge-pull-support-allow-unrelated-histories-options
[request] git merge/pull support `--allow-unrelated-histories ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 18908800812434-Commit-Push-Error
Commit/Push Error – IDEs Support (IntelliJ Platform) | JetBrains
May 13, 2024 - It also tells me to use “git pull” before pushing again. However upon using the git pull command, I get an error that state “fatal: refusing to merge unrelated histories”. Please help, I am now two weeks behind on my assignments and am struggling to catch up.
Find elsewhere
🌐
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).
🌐
JetBrains
youtrack.jetbrains.com › issue › IDEA-211533
Jetbrains
July 22, 2020 - {{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
YouTube
youtube.com › gina sprint
How to Fix the Git Error "fatal: refusing to merge unrelated histories." - YouTube
In this video I explain why you are getting the "fatal: refusing to merge unrelated histories" Git error when you try to push to Github and I show you two wa...
Published   February 9, 2020
Views   1K
🌐
JetBrains
youtrack.jetbrains.com › issue › IJPL-113763
How to merge two branches if they have no common ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
TutorialsPoint
tutorialspoint.com › article › how-to-solve-refusing-to-merge-unrelated-histories-in-git
How to solve Refusing to Merge Unrelated histories in Git?
August 8, 2023 - This command fetches the remote changes and merges them into the current branch. Here's an example ? git pull origin <branch-name> --allow-unrelated-histories · When faced with the error message "Refusing to merge unrelated histories in Git," it is crucial to adhere to certain guidelines for a smooth merging process.
🌐
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.
🌐
JetBrains
jetbrains.com › help › idea › apply-changes-from-one-branch-to-another.html
Merge, rebase, or cherry-pick to apply changes | IntelliJ IDEA Documentation
--allow-unrelated-histories: performs a merge, overriding the safety rule that refuses to merge histories without a common ancestor.
🌐
Medium
medium.com › @sahilali › 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 - The “fatal: refusing to merge ... a Git merge operation. It occurs when Git detects that the branches you are attempting to merge have diverged significantly and lack a common ancestor commit....
🌐
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.
🌐
Mazer.dev
mazer.dev › en › git › troubleshooting › how-to-fix-git-fatal-error-refusing-to-merge-unrelated-histories
How to fix Git fatal error: refusing to merge unrelated histories - Mazer.dev
October 1, 2022 - To solve this error just use the option allow-unrelated-histories. To allow GIT to make the merge of two projects with different histories, pass the parameter --uslow-unreard-histories when making the pull, like this:
🌐
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....
🌐
Junian Dev
junian.dev › tech › git-refusing-to-merge-unrelated-histories
How to Fix Git Refusing to Merge Unrelated Histories Issue
May 12, 2026 - Luckily, this is easy to fix. You just need to add the --allow-unrelated-histories option to your merge command. ... By default, the git merge command refuses to merge histories that do not share a common ancestor.