I had the same problem while using GitHub desktop. The way to solve is:

  1. Open repository folder in explorer
  2. Delete or rename the repository folder
  3. File -> clone repository and choose the right one
  4. Repeat step 1
  5. Copy your project to the folder
  6. Click "fetch origin"
Answer from ilya_kas on Stack Overflow
Discussions

"refusing to merge unrelated histories" with initial repository
Description There's a corner case where your local repository and remote repository can have distinct histories (because they were initialized with their own commit). We should surface this err... More on github.com
🌐 github.com
10
May 16, 2017
unable to merge unrelated histories
unable to merge unrelated histories in this repository More on github.com
🌐 github.com
2
September 15, 2019
'Unable to merge unrelated histories in this repository'
Trying to jump back in, but I'm not able to update my local repository with the GitHub desktop client—sorry for such a basic request, but can someone give me a hand with this? More on github.com
🌐 github.com
2
July 28, 2017
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
🌐
GitHub
github.com › desktop › desktop › issues › 1484
"refusing to merge unrelated histories" with initial repository · Issue #1484 · desktop/desktop
May 16, 2017 - There's a corner case where your local repository and remote repository can have distinct histories (because they were initialized with their own commit). We should surface this error, but what to do about it properly is an Excellent Question™. ... This is a bit convoluted, apologies. Create a new repository on GitHub, named whatever (I'm calling mine initialized-repository for future reference) and include a README so it gets an initial commit. Open Desktop and create a new repository with the same name (because consistent).
Author   desktop
🌐
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
🌐
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 - To fix the error, you can use the --allow-unrelated-histories option when running the git merge command. git merge --allow-unrelated-histories <branch-name> This option forces Git to proceed with the merge even if it cannot find a common ancestor ...
Find elsewhere
🌐
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 - If you are trying to merge two branches with unrelated histories, follow these steps: ... Replace main with your target branch and other-branch with the branch you are merging. git clone https://github.com/username/repository cd repository
🌐
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 ... automatically # Both sets of files now exist in your repo · Move one project into a subdirectory before merging to avoid conflicts....
🌐
GitHub
gist.github.com › kingluddite › 7ec82fdfa3700427efa0e5b97196dea6
unrelated-histories.md · GitHub
How to Resolve "Refusing to merge unrelated histories": 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: git pull origin <branch-name> --allow-unrelated-histories ...
🌐
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 › PageBot › PageBot › issues › 37
'Unable to merge unrelated histories in this repository' · Issue #37 · PageBot/PageBot
July 28, 2017 - 'Unable to merge unrelated histories in this repository'#37 · Copy link · MauriceMeilleur · opened · on Jul 28, 2017 · Issue body actions · Trying to jump back in, but I'm not able to update my local repository with the GitHub desktop client—sorry for such a basic request, but can someone give me a hand with this?
Author   PageBot
🌐
DEV Community
dev.to › omesha › solving-the-error-fatal-refusing-to-merge-unrelated-histories-491h
Solving the Error - "fatal: refusing to merge unrelated histories" - DEV Community
July 20, 2025 - As I really wanted to combine these repositories, I used a git command to allow the merge with a git option --allow-unrelated-histories ... and resolved the merge conflicts that came my way.
🌐
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.
🌐
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?

🌐
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"
Here are the commands for cloning and initializing: ... 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 ...
🌐
Stack Overflow
stackoverflow.com › questions › 70777472 › how-to-correct-unable-to-merge-unrelated-histories
github - How to correct «unable to merge unrelated histories»? - Stack Overflow
The alternative (and longer) way of fixing 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.
🌐
Educative
educative.io › answers › the-fatal-refusing-to-merge-unrelated-histories-git-error
The “fatal: refusing to merge unrelated histories” Git error
You have created a new repository, ... has no idea how the two projects are related. The error is resolved by toggling the allow-unrelated-histories switch....
🌐
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