【问题标题】:What is the difference between git subtree merge and git-subtreegit subtree merge 和 git-subtree 有什么区别
【发布时间】:2012-07-29 06:52:58
【问题描述】:
我刚刚发现了 git-subtree 工具,该工具前一段时间已成为主要 git repo 的一部分
https://github.com/apenwarr/git-subtree/
但是我不完全理解这个工具在现有的“git read-tree”+“git merge -s subtree”上提供了什么功能。 git-subtree 的唯一目的是让生成的提交历史看起来更好,还是它有更多我忽略的功能?
【问题讨论】:
标签:
git
git-merge
git-subtree
【解决方案1】:
您描述的命令将子树读入存储库。 git-subtree 命令有更多选项,如the documentation. 所述,除其他外,您可以(为简单起见加注释):
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 只是将它们包装起来,使它们更容易执行。