Search code examples
gitgit-subtree

Merging subtree split to another branch: Is it safe?


Suppose I have repository Foo with two branches: A and B. Branch A is an ancestor of branch B.

Let's say I setup a subtree in branch A, following the instructions in this guide. Once I have it all setup, what happens when I merge branch A into branch B later? Obviously I'd want branch B to naturally inherit the subtree just as if I had set it up again by hand on B. What will actually happen?


Solution

  • This page describes a bit about what subtree is actually doing:https://github.com/apenwarr/git-subtree/blob/master/git-subtree.txt

    It seems that if you want to merge your changes back in there is a git subtree merge command.

    At the same time, if you intend to merge the code back in, this might not be what you're looking for and rather you should just set up another branch off of A.

    You can also always branch off of B for a test branch and try doing the merge and seeing what happens. I find that just trying things out on test branches is often a good way to go.