🌐
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.
🌐
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:...
Discussions

Git refusing to merge unrelated histories on rebase - Stack Overflow
Then I checked out a local branch from the other repo and only then merged it and suddenly a normal merge commit appeared. Weird. 2016-12-13T13:49:26.807Z+00:00 ... Excellent, works with git pull as well. Was in that "rare event that merges histories of two projects that started their lives independently". git --work-tree="." pull --allow-unrelated... More on stackoverflow.com
🌐 stackoverflow.com
Simple question: how to blend two branches with diff commit histories
You can merge unrelated branches. https://reactgo.com/git-merge-unrelated-histories/ More on reddit.com
🌐 r/git
7
1
June 7, 2022
git - Merging two different repositories with different history - Stack Overflow
The --allow-unrelated-histories flag is new-ish; if git merge rejects it, you simply have an older Git that assumes the flag at all times. 2017-08-30T05:07:43.153Z+00:00 ... Save this answer. ... Show activity on this post. My suggestion is just to get one of the repo as principal (let's said first-repo), create a branch ... More on stackoverflow.com
🌐 stackoverflow.com
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
🌐
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. This flag tells Git to proceed with the merge despite the lack of a common commit ancestor.
🌐
Medium
spences10.medium.com › git-allow-unrelated-histories-a39a3814b981
Git ` — allow-unrelated-histories` | by Scott Spence | Medium
September 30, 2020 - git merge origin use-ts-bot --allow-unrelated-histories · This brought up, understandably, a few conflicts with the branch I wanted to merge with the origin.
🌐
Jeff Kreeftmeijer
jeffkreeftmeijer.com › git-combine
Combine Git repositories with unrelated histories
August 9, 2021 - To combine the two repositories, first add the second repository as a remote to the first. Then, run git fetch to fetch its branch information: ... Then, with the remote set up, merge the second repository’s history into the first by using the --allow-unrelated-histories flag:
🌐
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 ...
🌐
Wouter J
wouterj.nl › 2025 › 12 › merging-unrelated-repositories
Merging Unrelated Projects using Git ~ Wouter J
December 3, 2025 - ... # add a remote, pointing at the new Git project on my local filesystem $ git remote add local ~/projects/github.com/wouterj/docs-builder-new $ git fetch local $ git merge --allow-unrelated-histories local/main
Find elsewhere
🌐
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 - git merge --allow-unrelated-histories <branch-name> This option forces Git to proceed with the merge even if it cannot find a common ancestor between the branches.
🌐
GitHub
gist.github.com › kingluddite › 7ec82fdfa3700427efa0e5b97196dea6
unrelated-histories.md · GitHub
If you need to bring changes from one branch into another, you can use tools like git cherry-pick or create a patch. Remember that merging unrelated histories should be done with caution, as it can lead to a messy and confusing Git history.
🌐
Reddit
reddit.com › r/git › simple question: how to blend two branches with diff commit histories
r/git on Reddit: Simple question: how to blend two branches with diff commit histories
June 7, 2022 -

I have a dev branch I need to merge into my main branch. The dev branch I need to merge from a specific commit from Mar 1. The main branch has different commits up to Mar 20 and must be missing a lot from the dev branch. What is the best way of doing this? Trying to research it but the examples are obviously very generic so I figured I'd ask my specific problem in hopes of guidance.

🌐
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 - You can do this by using the --allow-unrelated-histories option with the git merge or git pull command. If you are trying to merge two branches with unrelated histories, follow these steps:
🌐
Reddit
reddit.com › r/git › merging unrelated histories
r/git on Reddit: Merging unrelated histories
November 21, 2020 -

I created the following repository on GitHub: https://github.com/james/test.git.

Then I proceeded with:

user@guest:~/.../gits$ git config --global init.defaultBranch main
user@guest:~/.../gits$ mkdir test && cd test
user@guest:~/.../test$ echo "# test" >> README.md
user@guest:~/.../test$ git init
user@guest:~/.../test$ git add README.md
user@guest:~/.../test$ git commit -m "First commit"
user@guest:~/.../test$ git remote add origin https://github.com/james/test.git
user@guest:~/.../test$ git push -u origin main

And then:

user@guest:~/.../test$ git commit --amend
user@guest:~/.../test$ git log --oneline --graph --all
* ca82a6d (HEAD -> main) First commit
* 085bb3b (origin/main) First commit
user@guest:~/.../test$ git merge origin/main
fatal: refusing to merge unrelated histories

What did I do wrong and what is the best solution in this case?

🌐
HackerNoon
hackernoon.com › how-to-merge-two-github-branches-with-entirely-different-stories-rk1n356n
How to Merge Two Github Branches with Entirely Different Stories | HackerNoon
April 7, 2021 - In our example, the almost empty main branch is the obvious selection as the branch to remove, so we need to replace that old disconnected main branch with a new one that shares the starting point of our development branch.
🌐
LinkedIn
linkedin.com › pulse › combining-unrelated-git-repositories-when-projects-collide-royer
Combining unrelated Git repositories: When Projects Collide!
May 7, 2022 - 1 cd path/to/project-b 2 git remote add project-a /path/to/project-a 3 git fetch project-a --tags 4 git merge --allow-unrelated-histories project-a/master # or whichever branch you want to merge 5 git remote remove project-a
🌐
GitHub
github.com › orgs › community › discussions › 132189
Merging a second branch with the main branch · community · Discussion #132189
July 14, 2024 - Remove: git branch -D main && git branch -m main && git push -f origin main Use instead: git fetch origin main && git merge origin/main --allow-unrelated-histories && git push origin main
🌐
Atlassian
jira.atlassian.com › browse › BCLOUD-15952
Support Git merge for branches with unrelated histories
Workaround is: do the merge locally by running: git pull origin master --allow-unrelated-histories git merge origin origin/master add and commit pit push origin master
🌐
GitKraken
feedback.gitkraken.com › suggestions › 231952 › support-merging-branches-with-unrelated-histories
Support merging branches with unrelated histories - GitKraken
November 11, 2021 - This mainly comes up when combining two separate git repositories while maintaining both of their commit histories (e.g., if I originally had source code and assets for a game in separate repos and am now combining them into one). This requires `git merge <branch> --allow-unrelated-histories` on ...
🌐
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 - Replace main with the name of the branch you want to rebase onto. git rebase origin/main --allow-unrelated-histories · If you're trying to merge instead of rebase, you can use the same flag with the git merge command.