git subtree error "fatal: refusing to merge unrelated histories"
If the subtree was added using --squash
, you need to also use --squash
when you pull
git subtree pull --prefix=<folder-goes-here> <remote-goes-here> <branch-goes-here> --squash
I've been struggling with this for a while and think I found the solution.
I'm pretty new to git so forgive me if I use the wrong names for things.
The problem may have come from you using the --squash
option when you ran the git subtree add command.
Try removing the subtree (remove the remote repository and delete all the local files, commit, and push). Then redo the subtree add without the --squash
option.
I then jumped over to my subtree repository, made some changes, committed and pushed, then hopped back to my main superproject repository and did a git subtree pull. It gave me some error about the working tree having modifications. To get around that I did a git checkout master, then a git push, then tried the subtree pull again. It worked.
Hope that helps.