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 - 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...
Author   desktop
🌐
GitHub
github.com › orgs › community › discussions › 132189
Merging a second branch with the main branch · community · Discussion #132189
July 14, 2024 - Merge help needed, considering force push. I am new to Github. I a recently made a branch and have done a ton of work on the second branch but it will not merge with my main branch. I get the error...
🌐
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 will display this error message if you try to merge two different projects. Fortunately, there is a command available to fix this issue!
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 - Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
🌐
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 - Learn why git refuses to merge unrelated histories and how to safely combine repositories that do not share a common ancestor.
🌐
GitHub
github.com › desktop › desktop › issues › 8279
unable to merge unrelated histories · Issue #8279 · desktop/desktop
September 15, 2019 - unable to merge unrelated histories in this repository
Author   desktop
🌐
GitHub
github.com › PageBot › PageBot › issues › 37
'Unable to merge unrelated histories in this repository' · Issue #37 · PageBot/PageBot
July 28, 2017 - 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
🌐
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?

🌐
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
I use github desktop (https://desktop.github.com ) while developing the application with several other people, so, for some reason, when trying to merge two branches into one, the error "unabl...
🌐
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 ... when two unrelated projects are merged (i.e., projects that are not aware of each other’s existence and have mismatching commit histories). Consider the following two cases that throw this error: You have cloned a project and, somehow, the .git directory got deleted or corrupted. This leads Git to be unaware of your local history and will, therefore, cause it to throw this error when you try to push to or pull from the remote repository...
🌐
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