しばらく前にメインのgitリポジトリの一部になったgit-subtreeツールを見つけました https://github.com/apenwarr/git-subtree/
ただし、このツールが既存の「gitread-tree」+「gitmerge-ssubtree」に対してどのような機能を提供するのか完全には理解していません。git-subtreeの唯一の目的は、結果のコミット履歴の見栄えを良くすることですか、それとも私が見落としていたより多くの機能を備えていることですか?
しばらく前にメインのgitリポジトリの一部になったgit-subtreeツールを見つけました https://github.com/apenwarr/git-subtree/
ただし、このツールが既存の「gitread-tree」+「gitmerge-ssubtree」に対してどのような機能を提供するのか完全には理解していません。git-subtreeの唯一の目的は、結果のコミット履歴の見栄えを良くすることですか、それとも私が見落としていたより多くの機能を備えていることですか?
説明するコマンドは、サブツリーをリポジトリに読み込みます。ドキュメントで説明されているように、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
それらをラップするだけで、実行がかなり簡単になります。
contribモジュールとしてgitに追加される前の古いサブツリーコードを見ると:https ://github.com/apenwarr/git-subtree/blob/master/git-subtree.shgitサブツリーツールであることがわかりますは実際には、低レベルのgitサブツリーマージ戦略のより高度なラッパーです。
基本的に、これらの戦略を賢明な方法で活用して、サブツリーの管理をはるかに簡単にします。特に--squashのものは本当に本当に便利です。
より多くのオプションがあることに加えて、git subtree
Git構成も考慮に入れます。
ただし、に関して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
と.gitconfig
、git subtree pull
エラーで失敗しますfatal: Not possible to fast-forward, aborting.
しかし、コマンドはこれらの場所でマージを行いたいと思っています。