Logging
Viewing The Commit History
To view the commit history, run
$ git log
To see the differences introduced in each commit and limit the entries to 2
$ git log -p -2
To see some stats for each commit
$ git log --stat
To see more readable options of the commits
$ git log --pretty=oneline
$ git log --pretty=short
$ git log --pretty=full
$ git log --pretty=fuller
You can specify the log format with the command
$ git log --pretty=format:"_OPTIONS_INSIDE_HERE_"
The available options can be found in the following table
Value | Option Description |
---|---|
%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 |
To print a graph with the branch and merge history
$ git log --graph
Limiting log output with --since or --until for e.g. weeks/years/days/minutes or specific dates "2008-01-15" or "2 years 1 day 3 minutes ago". The --author filter is also available
$ git log --since=2.weeks
To find the last commit that added or removed a reference to a specific function
$ git log -S _FUNCTION_NAME_
To list all your branches
$ git branch -a
A nice example of a graph is the following
$ git log --pretty=format:"%h %s" --graph