You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"refusing to merge unrelated histories" with initial repository #1484
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:
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 desktop/dugite#93 to track getting this into the Git bindings first.
This idea is interesting for the future, but this is beyond the scope of our current roadmap.
I'm going to add the future-proposal label to this issue and close it out, so that we don't get overwhelmed with our backlog! We'll revisit these as part of our next planning session.
I create a local repository and create another remote repository. then occur the warning
maybe, you cloud try:
git rebase
git pull
git push
Reacted by André Felipe C. Leite, Abdul-Quddus Yekeen, Gustavo Motta, Joshua Shields, Aravind Ganapathiraju, Jason Bornhoft, Muhamad Lutfi Alfiansyah, imarceloi, tina, mani and 6 more
@shiftkey This feels sufficiently edge-casey to potentially allow it to surface more frequently before we consider solving for it. Would you be ok with removing future proposal here?
Hey @shiftkey I've just reproduced this fault in 1.6.5, but no error is presented as in your initial post. I try to push, and I am informed the remote is newer than local, I should fetch the remote. Click Fetch, thinks for a second then goes away. Try to push again, rinse and repeat.
I had to go to the CLI to be presented with the error: "fatal: refusing to merge unrelated histories"
@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.
Reacted by Cyrus Furtado, Adrien Leloup, Andrew Bare, Giliane de Lima Braga, Zak Sadiq and Michael Grazebrook
Going to remove future proposal for now, with the caveat that this may resurface from users and we'll be able to reference this issue if/when it does. Thanks for clearly laying it out @shiftkey!
Activity
shiftkey commentedon Jun 24, 2017
There's a more descriptive error in here from an update to
duguite, but we need some flow around this to get the user to a happy place.Putting this aside for the moment.
joshaber commentedon Jun 29, 2017
Thanks for the suggestion!
This idea is interesting for the future, but this is beyond the scope of our current roadmap.
I'm going to add the
future-proposallabel to this issue and close it out, so that we don't get overwhelmed with our backlog! We'll revisit these as part of our next planning session.fy-kenny commentedon Oct 24, 2018
I create a local repository and create another remote repository. then occur the warning
maybe, you cloud try:
billygriffin commentedon Dec 19, 2018
@shiftkey This feels sufficiently edge-casey to potentially allow it to surface more frequently before we consider solving for it. Would you be ok with removing
future proposalhere?shiftkey commentedon Dec 20, 2018
@billygriffin yeah, I'm happy to let this sit. But keep in mind we've also seen #1308 #2247 and #5012 mention this particular Git error...
cookieuon commentedon Apr 14, 2019
Hey @shiftkey I've just reproduced this fault in 1.6.5, but no error is presented as in your initial post. I try to push, and I am informed the remote is newer than local, I should fetch the remote. Click Fetch, thinks for a second then goes away. Try to push again, rinse and repeat.
I had to go to the CLI to be presented with the error: "fatal: refusing to merge unrelated histories"
Hope this isn't in the wrong place.
steveward commentedon Apr 19, 2019
@cookieuon you can use the command
git pull origin master --allow-unrelated-historiesfrom the command line to force Git to merge the two separate repositories together. Let me know if you run into any issues with that.billygriffin commentedon Jun 17, 2019
Going to remove future proposal for now, with the caveat that this may resurface from users and we'll be able to reference this issue if/when it does. Thanks for clearly laying it out @shiftkey!
Mr-HaleYa commentedon Aug 25, 2020
Created a new repo, cloned it onto desktop, created a Readme.md using the website then tried uploading files and the error happens

The best way I found to deal with it is to create a new branch and push to that then merge afterward
tierninho commentedon Aug 25, 2020
@Mr-HaleYa Please open a new issue here https://github.com/desktop/desktop/issues/new?template=bug_report.md so we can address your situation independently. Thank you.