>

1. Display overall log info in a pretty way

$ git log --pretty=oneline

more detailed

$ git log --pretty=format:"%h - %an, %ar : %s"

Useful options for git log --pretty=format

Option Description of Output
%H Commit hash
%h Abbreviated commit hash
%T Tree hash
%t Abbreviated tree hash
%P Parent hashes
%p Abbreviated parent hashes
%an Author name
%ae Author email
%ad Author date (format respects the –date=option)
%ar Author date, relative
%cn Committer name
%ce Committer email
%cd Committer date
%cr Committer date, relative
%s Subject

Print log info with graph

$ git log --pretty=format:"%h %s" --graph

2. Check detailed info for all commits

$ git log --stat

$ git show --stat ${commit_hash}

$ git diff ${commit_hash} $(commint_hash)^

show last commit info

$ git log --stat -1

show last two commits info:

$ git log --stat -2

3. Check detailed commit info of a specific file

$ git log -p filename

##### More ---

git log has abundant format settings, to simplify the usage, we can

$ vim ~/.gitconfig
[alias]
    ll = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --numstat
    ld = log --pretty=format:"%C(yellow)%h\\ %C(green)%ad%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=short --graph
    ls = log --pretty=format:"%C(green)%h\\ %C(yellow)[%ad]%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate --date=relative

use git diff --cached to inspect changes in the cache/index (i.e. staged changes) against the current HEAD. --staged is a synonym for --cached.




Reference

https://git-scm.com/book/en/v2/Git-Basics-Viewing-the-Commit-History