7

したがって、各ブランチで「git log」または「git lg」を実行すると、完了したコミットのリストが表示されます。

さて、「git branch -arg」と入力したときに各ブランチの最新のコミットを表示する方法はありますか? 各ブランチをチェックアウトしてから、「git log」を使用してコミットをチェックする必要があるのは、少し面倒/面倒だと思います。

4

3 に答える 3

12

git branch -vブランチ名と、各ブランチの最新のコミットの SHA およびコミット メッセージを一覧表示します。

git ブランチのマニュアル ページを参照してください。

于 2012-07-17T14:11:42.827 に答える
4

はい、チェックアウト後のフックを追加できます (ここで説明します)。

基本的に、.git/hooks/post-checkoutファイルを作成し、実行したい任意の git コマンドを入れて、最後にそのファイルを実行可能にします ( chmod +x .git/hooks/post-checkoutMac OS、GNU/Linux などの UNIX ライクなシステムで)。

たとえば、git showそのファイルを配置すると、ブランチを切り替えるたびに、最後のコミットとどのような変更が行われたかが自動的に表示されます。

于 2012-07-17T14:05:54.350 に答える
2

出力を制御するための複数のgit logパラメーターがあります。

、、、のよう--branches--glob、表示するコミットを選択し、--tagすべての履歴を表示しないようにし(必要に応じてヒントだけ)、コミットログの最初の行のみを表示し、さらに目を楽しませます:D--remotes--no-walk--oneline--decorate--color=always

次のコマンドを試してください。

$ # show the first line of the commit message of all local branches
$ git log --oneline --decorate --color=always --branches --no-walk

$ # show the whole commit message of all the branches that start with "feature-"
$ git log --decorate --color=always --branches='feature-*' --no-walk

$ # show the last commit of all remote and local branches 
$ git log --decorate --color=always --branches --remotes --no-walk

$ # show the last commit of each remote branch
$ git fetch
$ git log --decorate --color=always --remotes --no-walk

ところで、他のブランチのコミットを確認するためにブランチを切り替える必要はありません。

$ # show the 'otherbranch' last commit message
$ git log --decorate --color=always -n 1 otherbranch

$ # show a cool graph of the 'otherbranch' history
$ git log --oneline --decorate --color=always --graph otherbranch
于 2012-07-17T14:33:55.870 に答える