Refused to merge unrelated histories error from git

SO here’s the error

   fae94dc..69acc07  main       -> origin/main
fatal: refusing to merge unrelated histories
VCSBaseException: VCS: Could not process command ['git', 'pull', '--recurse-submodules']

So I found a site that discussed the error and did the things it said to do to fix the problem. The first suggestion involved using ‘git pull origin master --allow-unrelated-histories.’ but I have no idea how to implement that in VSCode and/or platformIO.
So i followed the next suggestion using “Option 2: unstage, stash, clone, unstash, and then commit” but that didn’t fix the problem either. I’m a really new git user so I don’t understand what’s wrong. It seems to want to merge things but I have never knowingly created a branch so what is it trying to merge? Please help. I’m getting this error from pio pkg update trying to drag the changes to a library.


Sounds like this error occurs for you when trying to pull this library dependency during a PlatformIO build?

Just delete the .pio folder and let PIO cleanly redownload the depencneis upon the next build.

1 Like

That worked. Thanks.