14

しばらく前にメインのgitリポジトリの一部になったgit-subtreeツールを見つけました https://github.com/apenwarr/git-subtree/

ただし、このツールが既存の「gitread-tree」+「gitmerge-ssubtree」に対してどのような機能を提供するのか完全には理解していません。git-subtreeの唯一の目的は、結果のコミット履歴の見栄えを良くすることですか、それとも私が見落としていたより多くの機能を備えていることですか?

4

3 に答える 3

12

説明するコマンドは、サブツリーをリポジトリに読み込みます。ドキュメントで説明されているように、git-subtreeコマンドにはさらに多くのオプションがあります。特に、次のことができます(簡単にするために注釈を付けます)。

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それらをラップするだけで、実行がかなり簡単になります。

于 2012-07-31T14:24:16.453 に答える
5

contribモジュールとしてgitに追加される前の古いサブツリーコードを見ると:https ://github.com/apenwarr/git-subtree/blob/master/git-subtree.shgitサブツリーツールであることがわかりますは実際には、低レベルのgitサブツリーマージ戦略のより高度なラッパーです。

基本的に、これらの戦略を賢明な方法で活用して、サブツリーの管理をはるかに簡単にします。特に--squashのものは本当に本当に便利です。

于 2013-06-19T16:23:16.287 に答える
0

より多くのオプションがあることに加えて、git subtreeGit構成も考慮に入れます。

ただし、に関してgit subtree pullは、必ずGit2.36+を使用してください

git subtreeマージを作成する場合は、 " git merge" manを使用し、エンドユーザーの ""構成の影響を受けmerge.ffます。これは、Git 2.36(Q2 2022)で修正されています。

Thomas Koutcher()によるcommit 9158a35(2022年2月1日)を参照してください。( Junio C Hamanoによってマージされました---コミット0ac270c、2022年2月17日koutcher
gitster

subtree:強制マージコミット

サインオフ-作成者:Thomas Koutcher
レビュー者:Johannes Altmanninger

merge.ff設定するonly.gitconfiggit subtree pullエラーで失敗します

fatal: Not possible to fast-forward, aborting. 

しかし、コマンドはこれらの場所でマージを行いたいと思っています。

この動作を強制するには、 man--no-ffに引数を追加します。git merge

于 2022-02-20T10:29:10.837 に答える