したがって、各ブランチで「git log」または「git lg」を実行すると、完了したコミットのリストが表示されます。
さて、「git branch -arg」と入力したときに各ブランチの最新のコミットを表示する方法はありますか? 各ブランチをチェックアウトしてから、「git log」を使用してコミットをチェックする必要があるのは、少し面倒/面倒だと思います。
git branch -v
ブランチ名と、各ブランチの最新のコミットの SHA およびコミット メッセージを一覧表示します。
git ブランチのマニュアル ページを参照してください。
はい、チェックアウト後のフックを追加できます (ここで説明します)。
基本的に、.git/hooks/post-checkout
ファイルを作成し、実行したい任意の git コマンドを入れて、最後にそのファイルを実行可能にします ( chmod +x .git/hooks/post-checkout
Mac OS、GNU/Linux などの UNIX ライクなシステムで)。
たとえば、git show
そのファイルを配置すると、ブランチを切り替えるたびに、最後のコミットとどのような変更が行われたかが自動的に表示されます。
出力を制御するための複数の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