So I have a repository A. I want to push all the changes made (and the history) to another repository B. So, here's what i did:
git clone [A URL]
cd A // now i'm in the A directory (just to be clear)
git remote add TeamRepo [B URL] // adds the B repository as a remote
git push TeamRepo master // tries to push the changes to B repository
After last command, I have this error: fatal: refusing to merge unrelated histories
Can anyone help me with this? I found some kind of related articles, but they did not help me at all
The “fatal: refusing to merge unrelated histories” Git error occurs when two unrelated projects are merged (i.e., projects that are not aware of each other’s existence and have mismatching commit histories).
You have created a new repository (TeamRepo), added a few commits to it, and now you are trying to pull/push from a remote repository that already has some commits of its own. Git will also throw the error in this case, since it has no idea how the two projects are related.
Solution:
You can use --allow-unrelated-histories
to force the push to happen. Documentation