What is the difference between git subtree merge and git-subtree

邮差的信 提交于 2019-11-30 05:02:18

The commands you describe reads a subtree into a repository. The git-subtree command has many more options, as described by the documentation. Among others, you can (annotated for simplicity):

add::
    Create the <prefix> subtree by importing its contents
    from the given <refspec> or <repository> and remote <refspec>.
merge::
    Merge recent changes up to <commit> into the <prefix>
    subtree.
pull::
    Exactly like 'merge', but parallels 'git pull' in that
    it fetches the given commit from the specified remote
    repository.
push::
    Does a 'split' (see above) using the <prefix> supplied
    and then does a 'git push' to push the result to the 
    repository and refspec. This can be used to push your
    subtree to different branches of the remote repository.
split::
    Extract a new, synthetic project history from the
    history of the <prefix> subtree.  The new history
    includes only the commits (including merges) that
    affected <prefix>, and each of those commits now has the
    contents of <prefix> at the root of the project instead
    of in a subdirectory.  Thus, the newly created history
    is suitable for export as a separate git repository.

There are also a variety of flags that aid and manipulate the above. I believe all these options were available before via chains of plumbing commands. git-subtree.sh just wraps them and makes them considerably easier to execute.

If you look at the old subtree code before it got added to git as a contrib module: https://github.com/apenwarr/git-subtree/blob/master/git-subtree.sh you can see that the git subtree tool is really a more advanced wrapper around the lower level git subtree merging strategies.

It basically leverages those strategies in a sensible way to make subtree management much easier. Particularly the --squash stuff is really, really useful.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!