"refusing to merge unrelated histories" with initial repository
See original GitHub issueDescription
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™.
Version
GitHub Desktop version: 0.5.1
OS version: Windows 10
Steps to Reproduce
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). Ensure it at least has a README too. Make a note of where you saved it.
Here’s my setup:

- Launch
Repository
->Open command prompt
to open a shell - Run these command to wireup the repositories and the current branch:
git remote add origin https://github.com/{account}/{repo}.git -f
git branch -u origin/master
{account}
is the owner and {repo}
is whatever named you defined earlier - so for me this is:
git remote add origin https://github.com/shiftkey/initialized-repository.git -f
git branch -u origin/master
- Remove the repository, then drag-and-drop the folder to add it back in. This should light it up, and you should see this as your Pull button:

- Press
Pull
Expected behaviour: some guidance about resolving these two histories, favouring the remote repository
Actual behaviour: a basic error

And the console logs are kind of meh:
- The command `git -c credential.helper= pull --progress origin` exited with an unexpected code: 128. The caller should either handle this error, or expect that exit code.
(anonymous) @ core.ts:145
- core.ts:151 fatal: refusing to merge unrelated histories
(anonymous) @ core.ts:151
Reproduces how often: 100%
Additional Information
Some better messaging around this would be a good start while we figure out the solution path. I’ve opened https://github.com/desktop/dugite/issues/93 to track getting this into the Git bindings first.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (7 by maintainers)
I create a local repository and create another remote repository. then occur the warning maybe, you cloud try:
@cookieuon you can use the command
git pull origin master --allow-unrelated-histories
from the command line to force Git to merge the two separate repositories together. Let me know if you run into any issues with that.