Git subtree error "fatal: refusing to merge unrelated stories"

I am trying to understand how git subtree works. I followed all directions on this page , but I always get an error message trying to merge the subtree project into my own repo ("Step 2"): fatal: refusing to merge unrelated histories .

I read this post , and when I use the --allow-unrelated-histories , it works fine. However, I'm not sure if I should use this ... My impression is that the whole point of subtrees is to have unrelated stories in the same repository, so it is strange that this parameter needs to be added. Should I add it, though, or am I doing something wrong?

I am using git v2.9.3 on osx 10.11.6

+4
source share
2 answers

I struggled with this for a while and think I have found a solution.

I'm new to git, so forgive me if I use the wrong names for things.

You may have a problem using the --squash when running the add git command.

Try to remove the subtree (delete the remote repository and delete all local files, commit and click). Then repeat adding the subtree without the --squash option.

Then I jumped into my subtree repository, made some changes, committed and clicked, then jumped back to my main superproject repository and made the git tag. This gave me some error related to the fact that the working tree has modifications. To get around this, I did a git validation wizard, then hit git, and then tried the subtree again. It worked.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1258951/


All Articles