is it possible to display the latest commit when i use “git branch”?

So, on each branch if I do “git log” or “git lg”, it will show a list of commits done.

Now, is there a way to display the latest commit on each branch when I enter “git branch -arg”? I find it a bit annoying/tedious to have to checkout each branch then check the commits using “git log”.

  • how to format commit message for some people in git hook?
  • merge without merged branch commits history sourcetree
  • Updating docker images with small changes using commits
  • How can a patchfile created with `git-log -p <filename>` be applied to create all the commits included?
  • GIT Error:- expected committer email '' but found ''
  • git clone and checkout in a single command
  • Puppet Modules - Best Practices for Installing External Modules and Downloading Packages
  • How can I archive old git tags?
  • Git recommended workflow
  • prevent `git` from pushing commits with given commit message
  • Unable to install git
  • git log --follow, show all commits including merges
  • 3 Solutions collect form web for “is it possible to display the latest commit when i use “git branch”?”

    git branch -v lists branch names and the SHA and commit message of the latest commit on each branch.

    See the git branch manual page.

    Yes, you can add a post-checkout hook (described here).

    Basically, create the .git/hooks/post-checkout file and put whatever git command you want to run in it, and finally make sure to make that file executable (chmod +x .git/hooks/post-checkout on unix-like systems, such as Mac OS, GNU/Linux, etc).

    For example, if you put git show in that file, it will automatically show you the last commit and what changes were made whenever you switch branch.

    There are multiple git log parameters to control its output:

    Like --branches, --glob, --tag, --remotes to select which commits to show, --no-walk to avoid showing all their history (just their tips as you want), --oneline shows only the first line of commit logs, --decorate and --color=always add more eye candy 😀

    Try these commands:

    $ # 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

    BTW, there’s no need to switch branches to see other branch’s commits:

    $ # 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
    Git Baby is a git and github fan, let's start git clone.