Have you tried using (without -s subtree) -X subtree=path/to/add/subtree/at? >From the man page: subtree[=<path>] This option is a more advanced form of subtree strategy, where the strategy makes a guess on how two trees must be shifted to match with each other when merging. Instead, the specified path is prefixed (or stripped from the beginning) to make the shape of two trees to match. On Tue, Feb 7, 2017 at 2:16 AM, Stavros Liaskos <st.liaskos@xxxxxxxxx> wrote: > Following the instructions here: > https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging > will lead to an error. > > In particular, if the subtree is merged and then updated, this command > that is supposed to update the local subtree fails with a fatal: > refusing to merge unrelated histories error. > > $ git merge --squash -s subtree --no-commit rack_branch > > A workaround could be using the --allow-unrelated-histories option > > $ git merge --squash --allow-unrelated-histories -s subtree > --no-commit rack_branch > > But this completely destroys my project by pushing the subtree > contents into a completely irrelevant directory in my project (no in > the subtree). > > Any ideas?? > > https://github.com/git/git-scm.com/issues/896#issuecomment-277587626