首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >git子树合并和git-subtree有什么不同?

git子树合并和git-subtree有什么不同?
EN

Stack Overflow用户
提问于 2012-07-31 21:29:11
回答 2查看 5.2K关注 0票数 13

我刚刚发现git-subtree工具不久前成为主要git repo https://github.com/apenwarr/git-subtree/的一部分。

然而,我并不完全理解这个工具在已经存在的"git read-tree“+ "git merge -s subtree”上提供了什么功能。git-subtree的唯一用途是让结果提交历史看起来更好,还是它有更多我忽略了的功能?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-07-31 22:24:16

您描述的命令将子树读入存储库。正如the documentation.等人所描述的那样,git-subtree命令有更多选项,您可以(为简单起见对其进行注释):

代码语言:javascript
复制
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.

也有各种各样的标志来帮助和操纵上面的内容。我相信所有这些选项以前都是通过管道命令链提供的。git-subtree.sh只是包装了它们,并使它们更容易执行。

票数 12
EN

Stack Overflow用户

发布于 2013-06-20 00:23:16

如果你看一下以前的子树代码,然后将它作为一个contrib模块添加到git中:https://github.com/apenwarr/git-subtree/blob/master/git-subtree.sh,你会发现git子树工具实际上是一个更高级的包装器,它包含了更低级别的git子树合并策略。

它基本上以一种合理的方式利用这些策略,使子树管理变得更加容易。尤其是--壁球的东西真的非常有用。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11741249

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档