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

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
MAGIT Allow merging with unrelated histories
It looks like this can be done by using the transient library that is now used by magit. https://magit.vc/manual/transient/Modifying-Existing-Transients.html#Modifying-Existing-Transients After looking at a related page in the wiki that shows some examples ( https://github.com/magit/magit/wiki/Converting-popup-modifications-to-transient-modifications ), I came up with the following, which might be useful: (transient-append-suffix 'magit-merge "-s" '("-a" "Allow unrelated histories" "--allow-unrelated-histories")) It appends to the magit-merge prefix (submenu) after location "-s" (which is "Strategy") the suffix with keybinding -a, the given description and the given command-line argument. More on reddit.com
🌐 r/emacs
2
15
May 22, 2022
MAGIT Permitir merge con historiales no relacionados : r/emacs
🌐 r/emacs
June 5, 2025
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 ...
Can I use `--allow-unrelated-histories` with `git pull`?
Yes, you can use `--allow-unrelated-histories` with `git pull` to fetch and merge changes from a remote repository with a different commit history.
🌐
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 ...
🌐
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.
🌐
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
Find elsewhere
🌐
Better Stack
betterstack.com › community › questions › git-refusing-to-merge-unrelated-histories-on-rebase
Git Refusing to Merge Unrelated Histories on Rebase | Better Stack Community
By using the --allow-unrelated-histories option, you're explicitly telling Git to allow the merge or rebase operation even if the branches have unrelated histories.
🌐
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 - The “fatal: refusing to merge ... accidentally combining unrelated changes. To resolve the error, use the --allow-unrelated-histories flag cautiously....
🌐
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 ...
🌐
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"
If you are combining two distinct repositories, follow similar steps but ensure that you add both repositories as remotes and fetch changes from each. Use the --allow-unrelated-histories flag when merging their branches.
🌐
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 - There are two ways of solving the fatal: refusing to merge unrelated histories error. One way to solve the issue is to use the --allow-unrelated-histories git flag.
🌐
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.
🌐
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 ...
🌐
GeeksforGeeks
geeksforgeeks.org › git › how-to-merge-unrelated-histories-in-git
How to Merge Unrelated Histories in Git? - GeeksforGeeks
July 23, 2025 - Now, you can merge the unrelated histories by using the --allow-unrelated-histories flag.
🌐
GitHub
gist.github.com › kingluddite › 7ec82fdfa3700427efa0e5b97196dea6
unrelated-histories.md · GitHub
If you're certain that you want to merge the unrelated histories, you can force Git to do so with the --allow-unrelated-histories flag:
🌐
Namehero
namehero.com › blog › resolving-the-fatal-refusing-to-merge-unrelated-histories-error
Resolving the "Fatal: Refusing to Merge Unrelated Histories" Error
April 9, 2025 - So to proceed regardless, you must use the “–allow-unrelated-histories” flag to tell git that you know what you’re doing and that it’s deliberate.
🌐
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:
🌐
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.