Git Basics
git log
git log --pretty=format:"%h - %an, %ar : %s"
TABLE 2-1. 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
git log --pretty=format:"%h %s" --graph
TABLE 2-2. Common options to git log Option -p --stat --shortstat --name-only --name-status --abbrev-commit --relative-date --graph --pretty Description Show the patch introduced with each commit. Show statistics for files modified in each commit. Display only the changed/insertions/deletions line from the --stat command. Show the list of files modified a er the commit information. Show the list of files a ected with added/modified/deleted information as well. Show only the first few characters of the SHA-1 checksum instead of all 40. Display the date in a relative format (for example, “2 weeks ago”) instead of using the full date format. Display an ASCII graph of the branch and merge history be- side the log output. Show commits in an alternate format. Options include one- line, short, full, fuller, and format (where you specify your own format). 60
Limiting Log Output
TABLE 2-3. Options to limit the output of git log
Option Description
-(n) Show only the last n commits --since, --after --until, --before --author --committer --grep -S Limit the commits to those made a er the speci- fied date. Limit the commits to those made before the speci- fied date. Only show commits in which the author entry matches the specified string. Only show commits in which the committer entry matches the specified string. Only show commits with a commit message con- taining the string Only show commits adding or removing code matching the string Viewing the Commit History
Git Branching
Git Tools
Revision Selection
Rewrite History