I experienced this same issue when working on a new copy of an existing application.
I got the new copy of the existing application as a zip file and then unzipped it into a new folder.
And then I just copied some contents of the old copy of the existing application to the directory of the new copy of the existing application.
Afterwhich, I deleted the old copy of the existing application, and then I tried to push the new copy of the existing application to the remote repository of the existing application on Bitbucket.
And then it threw the error:
Unable to merge
Unrelated branches
Here's how I solved it:
The issue was that I did not copy the .git
directory of the old copy of the existing application into the new copy. The git directory stores information about the remote source repository. This information was lost when I trashed the old copy of the existing application.
All I had to do was to restore the old copy of the existing application from my Trash bin, and then I copied the .git
directory into the new copy of the existing application.
This time I tried to push to the remote source repository of the existing application and it worked amazingly fine.
Another workaround will be to do a fresh git clone
of the existing application from the remote repository and then copy the .git
directory from it into the new copy of the existing application. Afterwhich, I can then push back to the remote repository.
That's all.
I hope this helps