This page is not available in every language. Missing translations are disabled in the language selector.

Quick reference

Git Log Format String Placeholders Cheatsheet

A comprehensive reference guide for git log pretty formats: commit hashes, author/committer dates, subject and body placeholders, and ANSI color modifiers.

· Published

Git log allows extensive custom formatting of commit history output using --pretty=format:"..." format placeholders.

Usage

git log --pretty="format:%h - %an: %s (%cr)"

Commit & Tree Hashes

Placeholder Description
%H Full commit hash (40-character SHA-1)
%h Abbreviated commit hash
%T Full tree hash
%t Abbreviated tree hash
%P Full parent hashes
%p Abbreviated parent hashes

Author & Committer Metadata

Author (Original Creator)

Placeholder Description
%an Author name
%aN Author name respecting .mailmap
%ae Author email
%aE Author email respecting .mailmap
%ad Author date (format honors --date= option)
%aD Author date in RFC2822 style
%ar Author date, relative (e.g., "3 days ago")
%at Author date as UNIX epoch timestamp
%ai Author date in ISO 8601-like format
%aI Author date in strict ISO 8601 format

Committer (Person Applying Commit)

Placeholder Description
%cn Committer name
%cN Committer name respecting .mailmap
%ce Committer email
%cE Committer email respecting .mailmap
%cd Committer date (format honors --date= option)
%cD Committer date in RFC2822 style
%cr Committer date, relative
%ct Committer date as UNIX epoch timestamp
%ci Committer date in ISO 8601-like format
%cI Committer date in strict ISO 8601 format

Commit Messages

Placeholder Description
%s Subject line (first line of commit message)
%f Sanitized subject line suitable for filenames
%b Commit body (message excluding first line)
%B Raw body (entire subject and body intact)
%N Commit notes (git notes)
%GG Raw verification message from GPG signature
%G? GPG signature key status (G = good, B = bad, U = untrusted, N = none)
%GS GPG signer name
%GK GPG key ID used to sign commit

Colors & Formatting Modifiers

Placeholder Description
%Cred Switch terminal text color to red
%Cgreen Switch terminal text color to green
%Cblue Switch terminal text color to blue
%Creset Reset text formatting and colors
%C(color) Custom color spec (e.g. %C(yellow bold), %C(bold blue))
%m Left (<), right (>), or boundary (-) merge mark
%n Insert literal newline
%% Literal percent sign (%)
%x00 Insert character from hexadecimal ASCII/byte value

References

Related topics