Git Subtree. Why can't I branch from a subtree rather than the root?

前端 未结 2 673
半阙折子戏
半阙折子戏 2021-01-15 02:22

I am struggling trying to make sense of using the Git subtree strategy. My intent was to pull some disparate repos together into a little family of toy repos under an umbrel

相关标签:
2条回答
  • 2021-01-15 02:54

    I recommend apenwarr's git-subtree: http://github.com/apenwarr/git-subtree. Hopefully it gets added to git itself at some point.

    0 讨论(0)
  • 2021-01-15 03:05

    git works at the 'whole' tree level only, so wherever you are in your working tree operations like branch, checkout <branch>, commit all work at the root level.

    The subtree merge strategy is a merge strategy to help when you have a repository where one branch has moved a subtree of files to a different place in the repository and another side has made changes to those files in the original locations. It's designed to help merge these two operations in a way that a normal merge strategy would generate more conflicts or leave files in the wrong place.

    The subtree merge strategy has no bearing on the way the 'whole tree' operation of git works, so if you want make a branch that is just one subtree of a repository, you need to branch then make a new commit with the other subtrees removed and the tree of interest moved up to the root level.

    Given your usage pattern, though, I would recommend that you have long read up on submodules. It may provide functionality that suits what you are trying to achieve.

    0 讨论(0)
提交回复
热议问题