GIT-LOG(1)

๐ŸŽ€ GIT-LOG(1) ๐ŸŽ€ โ€” the Git Manual page, bestie ๐Ÿ’–

๐ŸŒธ NAME ๐ŸŒธ

git-log โ€” show commit logs. ๐Ÿ’…

โœจ SYNOPSIS โœจ

git log [<options>] [<revision-range>] [[--] <path>...]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

Okay so bestie, git log shows the commit logs. Thatโ€™s the whole assignment. ๐Ÿ’–

It lists commits that are reachable by following the parent links from the commit(s) you give it, but it excludes commits that are reachable from the one(s) that have a ^ in front of them. By default, the output comes in reverse chronological order, no cap. โณ

You can think of this as a set operation, fr fr. Commits reachable from any of the commits given on the command line form a set, and then commits reachable from any of the ones given with ^ in front are subtracted from that set. The remaining commits are what comes out in the commandโ€™s output. Various other options and paths parameters can be used to further limit the result. ๐Ÿซถ

So the following command:

$ git log foo bar ^baz

means "list all the commits which are reachable from foo or bar, but not from baz". Periodt.

A special notation, <commit1>..<commit2>, can be used as a short-hand for ^<commit1> <commit2>. For example, either of the following may be used interchangeably:

$ git log origin..HEAD
$ git log HEAD ^origin

Another special notation is <commit1>...<commit2>, which is useful for merges. The resulting set of commits is the symmetric difference between the two operands. The following two commands are equivalent:

$ git log A B --not $(git merge-base --all A B)
$ git log A...B

The command takes options applicable to the git-rev-list(1) command to control what is shown and how, and options applicable to the git-diff(1) command to control how the changes each commit introduces are shown. ๐Ÿ‘‘

๐Ÿ’… OPTIONS ๐Ÿ’…

  • --follow โ€” Continue listing the history of a file beyond renames (works only for a single file). Bestie, single file only โ€” thatโ€™s the rule. ๐Ÿ“
  • --no-decorate, --decorate[=(short|full|auto|no)] โ€” Print out the ref names of any commits that are shown. The option --decorate is short-hand for --decorate=short. Default to the configuration value of log.decorate if configured, otherwise, auto. Possible values are:
    • short โ€” the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ are not printed.
    • full โ€” the full ref name (including prefix) is printed.
    • auto โ€” if the output is going to a terminal, the ref names are shown as if short were given, otherwise no ref names are shown. โœจ
  • --decorate-refs=<pattern>, --decorate-refs-exclude=<pattern> โ€” For each candidate reference, do not use it for decoration if it matches any of the <pattern> parameters given to --decorate-refs-exclude or if it doesnโ€™t match any of the <pattern> parameters given to --decorate-refs. The log.excludeDecoration config option allows excluding refs from the decorations, but an explicit --decorate-refs pattern will override a match in log.excludeDecoration. If none of these options or config settings are given, then references are used as decoration if they match HEAD, refs/heads/, refs/remotes/, refs/stash/, or refs/tags/. ๐Ÿฆ‹
  • --clear-decorations โ€” When specified, this option clears all previous --decorate-refs or --decorate-refs-exclude options and relaxes the default decoration filter to include all references. This option is assumed if the config value log.initialDecorationSet is set to all. ๐Ÿ’œ
  • --source โ€” Print out the ref name given on the command line by which each commit was reached. Iconic. ๐ŸŽ€
  • --mailmap, --no-mailmap, --use-mailmap, --no-use-mailmap โ€” Use mailmap file to map author and committer names and email addresses to canonical real names and email addresses. See git-shortlog(1). ๐Ÿซถ
  • --full-diff โ€” The way that --full-diff works: without this flag, git log -p <path>... shows commits that touch the specified paths, and diffs about the same specified paths. With this, the full diff is shown for commits that touch the specified paths; this means that "<path>..." limits only commits, and doesnโ€™t limit diff for those commits. Note that this affects all diff-based output types, e.g. those produced by --stat, etc. ๐Ÿ”ฅ
  • --log-size โ€” Include a line log size <number> in the output for each commit, where <number> is the length of that commitโ€™s message in bytes. Itโ€™s literally intended to speed up tools that read log messages from git log output by allowing them to allocate space in advance. โšก
  • -L<start>,<end>:<file>, -L:<funcname>:<file> โ€” Trace the evolution of the line range given by <start>, <end>, or by the function name regex <funcname>, within the <file>. You may not give any pathspec limiters, iykyk. ๐Ÿ™ˆ This is currently limited to a walk starting from a single revision, i.e., you may only give zero or one positive revision arguments, and <start> and <end> (or <funcname>) must exist in the starting revision. You can specify this option more than once. Implies --patch. Patch output can be suppressed using --no-patch. Non-patch diff formats --raw, --name-only, --name-status, and --summary are supported. Diff stat formats (--stat, --numstat, --shortstat, --dirstat) are not currently implemented. Patch formatting options such as --word-diff, --color-moved, --no-prefix, and whitespace options (-w, -b) are supported, as are pickaxe options (-S, -G) and --diff-filter. <start> and <end> can take one of these forms:
    • <number> โ€” If <start> or <end> is a number, it specifies an absolute line number (lines count from 1).
    • /<regex>/ โ€” This form will use the first line matching the given POSIX <regex>. If <start> is a regex, it will search from the end of the previous -L range, if any, otherwise from the start of file. If <start> is ^/<regex>/, it will search from the start of file. If <end> is a regex, it will search starting at the line given by <start>.
    • +<offset> or -<offset> โ€” This is only valid for <end> and will specify a number of lines before or after the line given by <start>.
    • :<funcname> โ€” If given in place of <start> and <end>, it is a regular expression that denotes the range from the first funcname line that matches <funcname>, up to the next funcname line. :<funcname> searches from the end of the previous -L range, if any, otherwise from the start of file. ^:<funcname> searches from the start of file. The function names are determined in the same way as git diff works out patch hunk headers (see Defining a custom hunk-header in gitattributes(5)). ๐Ÿงš
  • <revision-range> โ€” Show only commits in the specified revision range. When no <revision-range> is specified, it defaults to HEAD โ€” main character energy, i.e. the whole history leading to the current commit. origin..HEAD specifies all the commits reachable from the current commit (i.e. HEAD), but not from origin. For a complete list of ways to spell <revision-range>, see the Specifying Ranges section of gitrevisions(7). ๐ŸŒˆ
  • [--] <path>... โ€” Show only commits that are enough to explain how the files that match the specified paths came to be. See History Simplification below for details and other simplification modes. Paths may need to be prefixed with -- to separate them from options or the revision range, when confusion arises. ๐Ÿ’ซ

๐Ÿšฆ Commit Limiting ๐Ÿšฆ

Besides specifying a range of commits that should be listed using the special notations explained in the description, additional commit limiting may be applied. ๐Ÿ‘‘

Vibe check: using more options generally further limits the output (e.g. --since=<date1> limits to commits newer than <date1>, and using it with --grep=<pattern> further limits to commits whose log message has a line that matches <pattern>), unless otherwise noted. ๐Ÿ’…

Note that these are applied before commit ordering and formatting options, such as --reverse. ๐ŸŽ€

  • -<number>, -n <number>, --max-count=<number> โ€” Limit the output to the first <number> commits that would be shown. โญ
  • --max-count-oldest=<number> โ€” Limit the output to the last <number> commits that would be shown. ๐Ÿ’–
  • --skip=<number> โ€” Skip <number> commits before starting to show the commit output. ๐Ÿฆ‹
  • --since=<date>, --after=<date> โ€” Show commits more recent than <date>. As a special case, today means the last midnight. โฐ
  • --since-as-filter=<date> โ€” Show all commits more recent than <date>. This visits all commits in the range, rather than stopping at the first commit which is older than <date>. ๐Ÿ”
  • --until=<date>, --before=<date> โ€” Show commits older than <date>. ๐Ÿ•ฐ๏ธ
  • --author=<pattern>, --committer=<pattern> โ€” Limit the commits output to ones with author/committer header lines that match the <pattern> regular expression. With more than one --author=<pattern>, commits whose author matches any of the <pattern> are chosen (similarly for multiple --committer=<pattern>). โœจ
  • --grep-reflog=<pattern> โ€” Limit the commits output to ones with reflog entries that match the <pattern> regular expression. With more than one --grep-reflog, commits whose reflog message matches any of the given patterns are chosen. It is an error to use this option unless --walk-reflogs is in use. ๐Ÿšจ
  • --grep=<pattern> โ€” Limit the commits output to ones with a log message that matches the <pattern> regular expression. With more than one --grep=<pattern>, commits whose message matches any of the <pattern> are chosen (but see --all-match). When --notes is in effect, lowkey the message from the notes is matched as if it were part of the log message. ๐Ÿ’Œ
  • --all-match โ€” Limit the commits output to ones that match all given --grep, instead of ones that match at least one. โœ…
  • --invert-grep โ€” Limit the commits output to ones with a log message that do not match the <pattern> specified with --grep=<pattern>. ๐Ÿ™ƒ
  • -i, --regexp-ignore-case โ€” Match the regular expression limiting patterns without regard to letter case. ๐Ÿ” 
  • --basic-regexp โ€” Consider the limiting patterns to be basic regular expressions; this is the default. ๐Ÿ“š
  • -E, --extended-regexp โ€” Consider the limiting patterns to be extended regular expressions instead of the default basic regular expressions. ๐Ÿง 
  • -F, --fixed-strings โ€” Consider the limiting patterns to be fixed strings (donโ€™t interpret pattern as a regular expression). ๐Ÿ”’
  • -P, --perl-regexp โ€” Consider the limiting patterns to be Perl-compatible regular expressions. Support for these types of regular expressions is an optional compile-time dependency. If Git wasnโ€™t compiled with support for them, providing this option will cause it to die. ๐Ÿ’€
  • --remove-empty โ€” dips out the moment a path stops existing in the tree. gone = stop โœ‹
  • --merges โ€” only merge commits, nothing else. literally identical to --min-parents=2, no cap ๐Ÿซถ
  • --no-merges โ€” the opposite vibe: hide anything with more than one parent. exactly the same as --max-parents=1 ๐Ÿ’…
  • --min-parents=<number>, --max-parents=<number>, --no-min-parents, --no-max-parents โ€” filter by how many parents a commit has, at least or at most. so --max-parents=1 = --no-merges, --min-parents=2 = --merges. and bestie, --max-parents=0 hands you all the root commits, while --min-parents=3 gives you every octopus merge ๐Ÿ™ (iconic behaviour honestly)

--no-min-parents and --no-max-parents reset those limits back to no-limit. the equivalent forms are --min-parents=0 (any commit has 0 or more parents) and --max-parents=-1 (negative numbers = no upper limit, yes really).

  • --first-parent โ€” when it's picking commits to include, it only follows the first parent once it hits a merge commit. this is lowkey the best overview when you're watching one topic branch evolve, because merges into a topic branch are usually just "adjusting to the updated upstream" โ€” so this lets you ignore all the individual commits that merge dragged into your history โœจ

heads up though: this also changes the default diff format for merge commits to first-parent, see --diff-merges=first-parent for the deets.

  • --exclude-first-parent-only โ€” same energy but for the excluding side: when finding commits to exclude (with a ^), follow only the first parent on a merge commit. great for finding the set of changes in a topic branch from the point where it diverged from the remote branch, given that arbitrary merges can be valid topic branch changes ๐Ÿ’–
  • --maximal-only โ€” restricts the output commits to only those that are not reachable from any other commits in the revision range. main character commits only ๐Ÿ‘‘
  • --not โ€” flips the meaning of the ^ prefix (or the lack of it) for every revision specifier that follows, right up until the next --not. and there's a lil subtlety: if you use it on the command line before --stdin, the revisions coming through stdin won't be affected by it. conversely, if you pass it via standard input, the revisions on the command line won't be affected by it. they don't share ๐Ÿซถ
  • --all โ€” pretend every ref in refs/, plus HEAD, was listed on the command line as <commit> ๐ŸŒˆ
  • --branches[=<pattern>] โ€” pretend all the refs in refs/heads got listed as <commit>. give it a <pattern> and it limits branches to ones matching that shell glob โ€” and if your pattern has no ?, *, or [, then /* at the end is implied ๐Ÿ‘€
  • --tags[=<pattern>] โ€” same deal but for refs/tags. <pattern> limits tags to the ones matching that shell glob, and again, if the pattern lacks ?, *, or [, then /* at the end is implied ๐ŸŽ€
  • --remotes[=<pattern>] โ€” you already know: pretend all refs in refs/remotes are on the command line as <commit>. <pattern> limits remote-tracking branches by shell glob, and if the pattern lacks ?, *, or [, then /* at the end is implied ๐Ÿ’œ
  • --glob=<glob-pattern> โ€” pretend every ref matching the shell glob <glob-pattern> was listed as <commit>. a leading refs/ gets auto-prepended if you forgot it. no ?, *, or [ in your pattern? then /* at the end is implied, periodt โญ
  • --exclude=<glob-pattern> โ€” nope, don't include refs matching <glob-pattern> that the next --all, --branches, --tags, --remotes, or --glob would've otherwise considered. repeating this option stacks up exclusion patterns until the next --all, --branches, --tags, --remotes, or --glob โ€” other options or arguments do not clear the pile ๐Ÿ™ˆ
real talk on the patterns: they should not begin with refs/heads, refs/tags, or refs/remotes when you're applying them to --branches, --tags, or --remotes respectively, and they must begin with refs/ when applied to --glob or --all. and if you want a trailing /*, you have to write it out explicitly. no vibes-based inference here.
  • --exclude-hidden=(fetch|receive|uploadpack) โ€” skip refs that git-fetch, git-receive-pack or git-upload-pack would hide, by consulting the matching fetch.hideRefs, receive.hideRefs or uploadpack.hideRefs config along with transfer.hideRefs (see git-config(1)). this one affects the next pseudo-ref option, --all or --glob, and it's cleared after they're processed ๐Ÿงš
  • --reflog โ€” pretend every object mentioned by reflogs was listed on the command line as <commit> ๐ŸŒธ
  • --alternate-refs โ€” pretend all objects mentioned as ref tips of alternate repositories got listed on the command line. an alternate repository is any repository whose object directory is specified in objects/info/alternates. heads up: the set of included objects may be modified by core.alternateRefsCommand, etc. โ€” see git-config(1) ๐Ÿฆ‹
  • --single-worktree โ€” by default, when you've got more than one working tree (see git-worktree(1)), these options examine all of them: --all, --reflog and --indexed-objects. this flag forces them to look at the current working tree only ๐Ÿ’…
  • --ignore-missing โ€” sees an invalid object name in the input? pretends the bad input was never given. gaslight, gatekeep, girlboss ๐Ÿ˜ญ
  • --bisect โ€” pretend the bad bisection ref refs/bisect/bad was listed, and as if it was followed by --not and the good bisection refs refs/bisect/good-* on the command line ๐Ÿ”ฅ
  • --stdin โ€” on top of getting arguments from the command line, read them from standard input too. accepts commits and pseudo-options like --all and --glob=. when a -- separator shows up, the input after it is treated as paths and used to limit the result. and ngl the scoping rules matter: flags like --not read via standard input are only respected for arguments passed the same way, and will not influence any subsequent command line arguments ๐Ÿซถ
  • --cherry-mark โ€” like --cherry-pick (below) but it marks equivalent commits with = instead of omitting them, and inequivalent ones with + โœจ
  • --cherry-pick โ€” omits any commit that introduces the same change as another commit on the "other side", when the set of commits is limited with symmetric difference. example time: if you have two branches, A and B, the usual way to list all commits on only one side is --left-right (see the example below in the description of the --left-right option). but that still shows commits that were cherry-picked from the other branch (like, "3rd on b" may be cherry-picked from branch A). with this option, those pairs of commits get excluded from the output ๐Ÿ“
  • --left-only, --right-only โ€” list only commits on the respective side of a symmetric difference, i.e. only those that --left-right would mark < resp. > respectively.

for example, --cherry-pick --right-only A...B omits those commits from B which are in A or are patch-equivalent to a commit in A. in other words, this lists the + commits from git cherry A B. more precisely, --cherry-pick --right-only --no-merges gives the exact list ๐Ÿ‘‘

  • --cherry โ€” a synonym for --right-only --cherry-mark --no-merges. useful for limiting output to the commits on our side and marking the ones that have been applied to the other side of a forked history, like git log --cherry upstream...mybranch, similar to git cherry upstream mybranch ๐Ÿ’œ
  • -g, --walk-reflogs โ€” instead of walking the commit ancestry chain, walk reflog entries from most recent to older ones. but bestie, when you use this you cannot specify commits to exclude โ€” that means ^<commit>, <commit1>..<commit2>, and <commit1>...<commit2> notations are straight-up off the table ๐Ÿšซ

with --pretty formats other than oneline and reference (for obvious reasons), this gives you two extra lines of info pulled from the reflog. the reflog designator in the output may show as ref@{<Nth>} (where <Nth> is the reverse-chronological index in the reflog) or as ref@{<timestamp>} (with the <timestamp> for that entry), depending on a few rules:

  1. If the starting point is specified as ref@{<Nth>}, show the index format.
  2. If the starting point was specified as ref@{now}, show the timestamp format.
  3. If neither was used, but --date was given on the command line, show the timestamp in the format requested by --date.
  4. Otherwise, show the index format.

under --pretty=oneline, the commit message is prefixed with this information on the same line. and this option cannot be combined with --reverse โ€” that combo is a no ๐Ÿ’€. see also git-reflog(1).

under --pretty=reference, this information will not be shown at all ๐Ÿ™ˆ

  • --merge โ€” shows commits touching conflicted paths in the range HEAD...<other>, where <other> is the first existing pseudoref in MERGE_HEAD, CHERRY_PICK_HEAD, REVERT_HEAD or REBASE_HEAD. only works when the index has unmerged entries. this is the one for showing relevant commits while you're resolving conflicts from a 3-way merge ๐Ÿ”ฅ
  • --boundary โ€” outputs excluded boundary commits. boundary commits are prefixed with - โญ

๐ŸŒธ HISTORY SIMPLIFICATION ๐ŸŒธ

sometimes you only care about parts of the history โ€” like, the commits touching one particular <path>. but there are two parts to History Simplification, bestie: one part is selecting the commits, and the other part is how to do it, because there are various strategies to simplify the history ๐Ÿฆ‹

the following options select the commits to be shown:

  • <paths> โ€” commits modifying the given <paths> are selected.
  • --simplify-by-decoration โ€” commits that are referred to by some branch or tag are selected.

note that extra commits can be shown to give a meaningful history โ€” that's by design, don't @ it ๐Ÿ’…

the following options affect the way the simplification is performed:

Default mode

simplifies the history to the simplest history explaining the final state of the tree. simplest because it prunes some side branches if the end result is the same (i.e. merging branches with the same content) โœจ

--show-pulls

includes all commits from the default mode, but also any merge commits that are not TREESAME to the first parent but are TREESAME to a later parent. this mode is helpful for showing the merge commits that "first introduced" a change to a branch ๐ŸŒˆ

--full-history

same as the default mode, but it does not prune some history. that's the whole difference, no cap ๐Ÿซถ

  • --dense โ€” only the commits you actually picked show up, plus a few extras so the history still makes sense. basically the "keep it cute, keep it minimal" setting โœจ
  • --sparse โ€” every commit in the simplified history gets shown. no filtering, no hiding, all of them ๐Ÿ’…
  • --simplify-merges โ€” this is an add-on to --full-history, and what it does is prune away merges that are genuinely pointless, because no selected commit actually contributes anything to that merge. bye bye clutter ๐Ÿงน
  • **--ancestry-path[=<commit>]** โ€” okay so, when you're looking at a range of commits (like <commit1>..<commit2>or<commit2> ^<commit1>) and there's a commit <commit>inside that range, this only shows you commits in the range that are ancestors of<commit>, descendants of <commit>, or <commit>itself. if you don't name a commit, it uses<commit1>(the excluded side of the range) as<commit>`. you can pass it multiple times too โ€” and if you do, a commit gets included if it's any one of the commits you gave, or an ancestor or descendant of any one of them ๐Ÿฆ‹

๐ŸŒธ a more detailed explanation follows (grab a snack bestie)

So suppose you specified foo as the <paths>. Commits that modify foo? We're calling those !TREESAME. Everything else is TREESAME. (In a diff filtered for foo, they look different and equal, respectively. that's literally the whole bit ๐Ÿ’€)

In everything below, we're always referring to the same example history, so you can actually see the difference between the simplification settings. We're assuming you're filtering for a file foo in this commit graph:

              .-A---M---N---O---P---Q
             /     /   /   /   /   /
            I     B   C   D   E   Y
             \   /   /   /   /   /
              `-------------'   X

The horizontal line of history A---Q is taken to be the first parent of each merge. And the commits are:

  • I is the initial commit โ€” foo exists in it with contents asdf, and a file quux exists with contents quux. Initial commits get compared to an empty tree, so I is !TREESAME ๐Ÿ‘‘
  • In A, foo contains just foo.
  • B contains the same change as A. Its merge M is trivial and hence TREESAME to all parents.
  • C does not change foo, but its merge N changes it to foobar, so it is not TREESAME to any parent.
  • D sets foo to baz. Its merge O combines the strings from N and D to foobarbaz; i.e., it is not TREESAME to any parent.
  • E changes quux to xyzzy, and its merge P combines the strings to quux xyzzy. P is TREESAME to O, but not to E.
  • X is an independent root commit that added a new file side, and Y modified it. Y is TREESAME to X. Its merge Q added side to P, and Q is TREESAME to P, but not to Y.

So rev-list walks backwards through history, including or excluding commits depending on whether --full-history and/or parent rewriting (via --parents or --children) are used. Here are the settings available to you ๐ŸŽ€

Default mode

Commits are included if they're not TREESAME to any parent (though this can be changed โ€” see --sparse below). If the commit was a merge, and it was TREESAME to one parent, follow only that parent. (Even if there are several TREESAME parents, follow only one of them.) Otherwise, follow all parents.

Which results in:

              .-A---N---O
             /     /   /
            I---------D

Notice how that rule โ€” only follow the TREESAME parent if one's available โ€” removed B from consideration entirely. C was considered via N, but is TREESAME. Root commits are compared to an empty tree, so I is !TREESAME.

Parent/child relations are only visible with --parents, but that doesn't affect which commits get selected in default mode, so we've shown the parent lines anyway ๐Ÿซถ

--full-history without parent rewriting

This mode differs from the default in exactly one way: it always follows all parents of a merge, even if it's TREESAME to one of them. And even if more than one side of the merge has commits that are included, that does not mean the merge itself is included! In the example, we get:

I A B N D O P Q

M was excluded because it's TREESAME to both parents. E, C and B were all walked, but only B was !TREESAME, so the others don't appear.

ngl, without parent rewriting it's not really possible to talk about the parent/child relationships between the commits, so we show them disconnected. it's giving scattered ๐Ÿ˜ญ

--full-history with parent rewriting

Ordinary commits are only included if they're !TREESAME (though, again, this can be changed โ€” see --sparse below).

Merges are always included. But their parent list gets rewritten: along each parent, prune away commits that aren't included themselves. That gives us:

              .-A---M---N---O---P---Q
             /     /   /   /   /
            I     B   /   D   /
             \   /   /   /   /
              `-------------'

Compare that to --full-history without rewriting up above. Note that E was pruned away because it's TREESAME, but the parent list of P was rewritten to contain E's parent I. Same thing happened for C and N, and for X, Y and Q. iconic behavior honestly โœจ


On top of all the settings above, you can also change whether TREESAME affects inclusion:

  • --dense โ€” commits that are walked are included if they're not TREESAME to any parent.
  • --sparse โ€” all commits that are walked are included.
heads up bestie: without --full-history, this still simplifies merges โ€” if one of the parents is TREESAME, we follow only that one, so the other sides of the merge are never walked at all ๐Ÿฆ‹
  • --simplify-merges โ€” first, build a history graph the same way --full-history with parent rewriting does (see above). Then simplify each commit C to its replacement C' in the final history, according to these rules:
    1. Set C' to C.
    2. Replace each parent P of C' with its simplification P'. In the process, drop parents that are ancestors of other parents or that are root commits TREESAME to an empty tree, and remove duplicates โ€” but take care to never drop all parents that we are TREESAME to.
    3. If after this parent rewriting, C' is a root or merge commit (has zero or >1 parents), a boundary commit, or !TREESAME, it remains. Otherwise, it's replaced with its only parent.

The effect of this is best shown by comparing to --full-history with parent rewriting. The example turns into:

              .-A---M---N---O
             /     /       /
            I     B       D
             \   /       /
              `---------'

Note the major differences in N, P, and Q over --full-history:

  • N's parent list had I removed, because it's an ancestor of the other parent M. Still, N remained because it's !TREESAME.
  • P's parent list similarly had I removed. P was then removed completely, because it had one parent and is TREESAME.
  • Q's parent list had Y simplified to X. X was then removed, because it was a TREESAME root. Q was then removed completely, because it had one parent and is TREESAME.

There's another simplification mode available too:

  • --ancestry-path[=<commit>] โ€” limit the displayed commits to those which are an ancestor of <commit>, or which are a descendant of <commit>, or are <commit> itself. ๐Ÿ‘‘

As an example use case, consider this commit history:

                D---E-------F
               /     \       \
              B---C---G---H---I---J
             /                     \
            A-------K---------------L--M

A regular D..M computes the set of commits that are ancestors of M, but excludes the ones that are ancestors of D. That's useful for seeing what happened to the history leading to M since D โ€” in the sense of "what does M have that didn't exist in D". The result in this example would be all the commits, except A and B (and D itself, obviously).

But when we want to find out which commits in M are contaminated with the bug introduced by D and need fixing, we might want to view only the subset of D..M that are actually descendants of D โ€” i.e. excluding C and K. That is exactly what the --ancestry-path option does. Applied to the D..M range, it results in:

                    E-------F
                     \       \
                      G---H---I---J
                                   \
                                    L--M

We can also use --ancestry-path=D instead of --ancestry-path โ€” it means the same thing when applied to the D..M range, it's just more explicit about it ๐Ÿ’…

If instead we're interested in a given topic within this range, and all the commits affected by that topic, we might only want to view the subset of D..M which contain that topic in their ancestry path. So using --ancestry-path=H D..M for example would result in:

                    E
                     \
                  C---G---H---I---J
                                   \
                                    L--M

Whereas --ancestry-path=K D..M would result in:

K---------------L--M


Okay so before we talk about another option, --show-pulls, we need to create a new example history. ๐Ÿงš

A common problem users face when looking at simplified history is that a commit they know changed a file somehow just... doesn't appear in the file's simplified history. Let's demonstrate with a new example and show how options like --full-history and --simplify-merges work in that case:

              .-A---M-----C--N---O---P
             /     / \  \  \/   /   /
            I     B   \  R-'`-Z'   /
             \   /     \/         /
              \ /      /\        /
               `---X--'  `---Y--'

For this example, suppose I created file.txt, which was modified by A, B, and X in different ways. The single-parent commits C, Z, and Y do not change file.txt. The merge commit M was created by resolving the merge conflict to include both changes from A and B, and hence is not TREESAME to either. The merge commit R, however, was created by ignoring the contents of file.txt at M and taking only the contents of file.txt at X. Hence, R is TREESAME to X but not M. Finally, the natural merge resolution to create N is to take the contents of file.txt at R, so N is TREESAME to R but not C. The merge commits O and P are TREESAME to their first parents, but not to their second parents, Z and Y respectively.

When using the default mode, N and R both have a TREESAME parent, so those edges get walked and the others get ignored. The resulting history graph is:

I---X

Okay so when you're on --full-history, Git literally walks every single edge โ€” no skipping, no shortcuts. This is gonna find you commits A and B and that merge M, but it also drags the merge commits O and P out into the light. With parent rewriting on, the resulting graph is giving:

              .-A---M--------N---O---P
             /     / \  \  \/   /   /
            I     B   \  R-'`--'   /
             \   /     \/         /
              \ /      /\        /
               `---X--'  `------'

And here's the tea: those merge commits O and P are pure noise, bestie. They did not actually contribute a change to file.txt. All they did was merge a topic that was based on an older version of file.txt โ€” that's it, that's the whole contribution. ๐Ÿ˜ญ This is lowkey a super common issue in repos using a workflow where tons of contributors work in parallel and merge their topic branches along a single trunk, and the result is that many unrelated merges pop up in your --full-history results. Annoying? A little.


Now when you hit it with the --simplify-merges option, commits O and P just... vanish from the results. ๐Ÿ’… Why? Because the rewritten second parents of O and P are reachable from their first parents. Those edges get removed, and then the commits look like single-parent commits that are TREESAME to their parent. Same thing happens to commit N, so your history view ends up like this:

                .-A---M--.
               /     /    \
              I     B      R
               \   /      /
                \ /      /
                 `---X--'

In this view we're seeing all the important single-parent changes from A, B, and X โ€” slay โ€” plus the carefully-resolved merge M and the not-so-carefully-resolved merge R. ๐Ÿ™ˆ This is usually enough info to figure out why commits A and B "disappeared" from history in the default view. But bestie, there are a couple of issues with this approach, and I'm not gonna gatekeep them.

The first issue is performance. Unlike literally any previous option, the --simplify-merges option requires walking the entire commit history before it returns even a single result. So like, yeah, this can make the option difficult to use for very large repositories. ๐Ÿ˜ฌ Plan accordingly.

The second issue is one of auditing. When lots of contributors are working on the same repository, it highkey matters which merge commits introduced a change into an important branch. That problematic merge R above? It's not likely to be the merge commit that was actually used to merge into an important branch. Instead, the merge N was the one used to merge R and X into the important branch. And that commit might have info in its commit message about why the change X came to override the changes from A and B. iykyk โ€” commit messages are lore.

  • --show-pulls โ€” so on top of the commits shown in the default history, this shows each merge commit that is not TREESAME to its first parent but is TREESAME to a later parent. ๐Ÿซถ

When a merge commit gets included by --show-pulls, the merge is treated as if it "pulled" the change from another branch. When you use --show-pulls on this example (and no other options), the resulting graph is:

            I---X---R---N

Here, the merge commits R and N are included because they pulled the commits X and R into the base branch, respectively. These merges are literally the reason the commits A and B don't appear in the default history. ๐Ÿ”ฅ

When --show-pulls is paired with --simplify-merges, the graph includes all of the necessary info:

              .-A---M--.   N
             /     /    \ /
            I     B      R
             \   /      /
              \ /      /
               `---X--'

Notice that since M is reachable from R, the edge from N to M was simplified away. But N still appears in the history as an important commit because it "pulled" the change R into the main branch. Iconic behavior honestly.


The --simplify-by-decoration option lets you view only the big picture of the topology of the history, by omitting commits that are not referenced by tags. โœจ Commits are marked as !TREESAME (in other words, kept after history simplification rules described above) if (1) they are referenced by tags, or (2) they change the contents of the paths given on the command line. All other commits are marked as TREESAME (subject to be simplified away). Simple as that, bestie.

๐ŸŒธ Commit Ordering ๐ŸŒธ

By default, the commits are shown in reverse chronological order. Classic.

  • --date-order โ€” show no parents before all of its children are shown, but otherwise show commits in the commit timestamp order. โฐ
  • --author-date-order โ€” show no parents before all of its children are shown, but otherwise show commits in the author timestamp order. โœ๏ธ
  • --topo-order โ€” show no parents before all of its children are shown, and avoid showing commits on multiple lines of history intermixed. This one's the neat freak of the group.

For example, in a commit history like this:

        ---1----2----4----7
            \              \
             3----5----6----8---

where the numbers denote the order of commit timestamps, git rev-list and friends with --date-order show the commits in the timestamp order: 8 7 6 5 4 3 2 1.

With --topo-order, they would show 8 6 5 3 7 4 2 1 (or 8 7 4 2 6 5 3 1); some older commits are shown before newer ones in order to avoid showing the commits from two parallel development tracks mixed together. ๐ŸŒ€

  • --reverse โ€” output the commits chosen to be shown (see Commit Limiting section above) in reverse order. Cannot be combined with --walk-reflogs. ๐Ÿšซ

๐Ÿฆ‹ Object Traversal ๐Ÿฆ‹

These options are mostly targeted for packing of Git repositories. Very much a "behind the scenes" moment, but we respect them.

  • --no-walk[=(sorted|unsorted)] โ€” only show the given commits, but do not traverse their ancestors. This has no effect if a range is specified. If the argument unsorted is given, the commits are shown in the order they were given on the command line. Otherwise (if sorted or no argument was given), the commits are shown in reverse chronological order by commit time. Cannot be combined with --graph. ๐Ÿ™…
  • --do-walk โ€” overrides a previous --no-walk. That's it. That's the whole thing. ๐Ÿ’…

๐ŸŽ€ Commit Formatting ๐ŸŽ€

  • --pretty[=<format>], --format=<format> โ€” pretty-print the contents of the commit logs in a given format, where <format> can be one of oneline, short, medium, full, fuller, reference, email, raw, format:<string> and tformat:<string>. When <format> is none of the above, and has %<placeholder> in it, it acts as if --pretty=tformat:<format> were given. ๐Ÿคฏ

See the "PRETTY FORMATS" section for some additional details for each format. When the =<format> part is omitted, it defaults to medium.

Note: you can specify the default pretty format in the repository configuration (see git-config(1)). ๐Ÿซถ
  • --abbrev-commit โ€” instead of showing the full 40-byte hexadecimal commit object name, show a prefix that names the object uniquely. --abbrev=<n> (which also modifies diff output, if it is displayed) option can be used to specify the minimum length of the prefix.

This should make --pretty=oneline a whole lot more readable for people using 80-column terminals. ๐Ÿ‘‘

  • --no-abbrev-commit โ€” show the full 40-byte hexadecimal commit object name. This negates --abbrev-commit, either explicit or implied by other options such as --oneline. It also overrides the log.abbrevCommit variable. ๐Ÿ”ฅ
  • --oneline โ€” this is a shorthand for --pretty=oneline --abbrev-commit used together. Short and sweet.
  • --encoding=<encoding> โ€” commit objects record the character encoding used for the log message in their encoding header; this option can be used to tell the command to re-code the commit log message in the encoding preferred by the user. For non plumbing commands this defaults to UTF-8. Note that if an object claims to be encoded in X and we are outputting in X, we will output the object verbatim; this means that invalid sequences in the original commit may be copied to the output. Likewise, if iconv(3) fails to convert the commit, we will quietly output the original object verbatim. ๐Ÿ’€ So like, no error, just vibes.
  • --expand-tabs=<n>, --expand-tabs, --no-expand-tabs โ€” perform a tab expansion (replace each tab with enough spaces to fill to the next display column that is a multiple of <n>) in the log message before showing it in the output. --expand-tabs is a short-hand for --expand-tabs=8, and --no-expand-tabs is a short-hand for --expand-tabs=0, which disables tab expansion.

By default, tabs are expanded in pretty formats that indent the log message by 4 spaces (i.e. medium, which is the default, full, and fuller). ๐Ÿงš

  • --notes[=<ref>] โ€” show the notes (see git-notes(1)) that annotate the commit, when showing the commit log message. This is the default for git log, git show and git whatchanged commands when there is no --pretty, --format, or --oneline option given on the command line.

By default, the notes shown are from the notes refs listed in the core.notesRef and notes.displayRef variables (or corresponding environment overrides). See git-config(1) for more details.

With an optional <ref> argument, use the ref to find the notes to display. The ref can specify the full refname when it begins with refs/notes/; when it begins with notes/, refs/ and otherwise refs/notes/ is prefixed to form the full name of the ref.

Multiple --notes options can be combined to control which notes are being displayed. Examples: "--notes=foo" will show only notes from refs/notes/foo; "--notes=foo --notes" will show both notes from "refs/notes/foo" and from the default notes ref(s). ๐Ÿ’œ

  • --no-notes โ€” do not show notes. This negates the above --notes option, by resetting the list of notes refs from which notes are shown. Options are parsed in the order given on the command line, so e.g. "--notes --notes=foo --no-notes --notes=bar" will only show notes from refs/notes/bar. Order matters, bestie! ๐ŸŽฏ
  • --show-notes-by-default โ€” show the default notes unless options for displaying specific notes are given. ๐ŸŒธ
  • --show-notes[=<ref>], --standard-notes, --no-standard-notes โ€” these options are deprecated. โš ๏ธ Use the above --notes/--no-notes options instead.
  • --show-signature โ€” check the validity of a signed commit object by passing the signature to gpg --verify and show the output. ๐Ÿ”
  • --relative-date โ€” synonym for --date=relative. That's the whole description, no cap.
  • --date=<format> โ€” only takes effect for dates shown in human-readable format, such as when using --pretty. The log.date config variable sets a default value for the log command's --date option. By default, dates are shown in the original time zone (either committer's or author's). If -local is appended to the format (e.g., iso-local), the user's local time zone is used instead. ๐ŸŒˆ
  • --date=relative โ€” shows dates relative to right now, like 2 hours ago. Heads up bestie: the -local option does nothing here, zero effect, don't come for me.
  • --date=local โ€” literally just an alias for --date=default-local. That's it. That's the whole vibe.
  • --date=iso (or --date=iso8601) โ€” timestamps in an ISO 8601-like format. It's giving ISO but it's not fully committed ๐Ÿ˜ญ the differences from strict ISO 8601 are:
    • a space instead of the T date/time delimiter
    • a space between time and time zone
    • no colon between hours and minutes of the time zone
  • --date=iso-strict (or --date=iso8601-strict) โ€” now this one is strict ISO 8601, no cap. Full commitment.
  • --date=rfc (or --date=rfc2822) โ€” RFC 2822 format, the one you see all the time in email messages. Very "as per my last email" of it.
  • --date=short โ€” date only, no time, in YYYY-MM-DD format. Minimalist queen.
  • --date=raw โ€” shows the date as seconds since the epoch (1970-01-01 00:00:00 UTC), then a space, then the timezone as an offset from UTC (a + or - with four digits; the first two are hours, and the second two are minutes). I.e., as if the timestamp were formatted with strftime("%s %z"). Lowkey important: the -local option does not affect the seconds-since-epoch value (which is always measured in UTC), but it does switch the accompanying timezone value. Sneaky but slay.
  • --date=human โ€” shows the timezone if the timezone doesn't match the current time-zone, and doesn't print the whole date if that matches (ie skip printing year for dates that are "this year", but also skip the whole date itself if it's in the last few days and we can just say what weekday it was). For older dates the hour and minute is also omitted. It's the "girl, you know when" of date formats ๐Ÿซถ
  • --date=unix โ€” date as a Unix epoch timestamp (seconds since 1970). Same energy as --raw: this is always in UTC and therefore -local has no effect.
  • --date=format:<format> โ€” feeds the <format> to your system strftime, except for %s, %z, and %Z, which are handled internally. Use --date=format:%c to show the date in your system locale's preferred format. Peep the strftime(3) manual for a complete list of format placeholders. And when using -local, the correct syntax is --date=format-local:<format> โ€” write that down โœจ
  • --date=default โ€” the default format, based on ctime(3) output. It shows a single line with three-letter day of the week, three-letter month, day-of-month, hour-minute-seconds in "HH:MM:SS" format, followed by 4-digit year, plus timezone information, unless the local time zone is used, e.g. Thu Jan 1 00:00:00 1970 +0000. Classic, iconic, the moment.

  • --parents โ€” print also the parents of the commit (in the form "commit parent..."). Also enables parent rewriting, see History Simplification above. Family tree behavior ๐Ÿ’…
  • --children โ€” print also the children of the commit (in the form "commit child..."). Also enables parent rewriting, see History Simplification above. Now we're going down the tree, obsessed.
  • --left-right โ€” mark which side of a symmetric difference a commit is reachable from. Commits from the left side are prefixed with < and those from the right with >. If combined with --boundary, those commits are prefixed with -.

For example, if you have this topology:

                            y---b---b  branch B
                           / \ /
                          /   .
                         /   / \
                        o---x---a---a  branch A

you would get an output like this:

$ git rev-list --left-right --boundary --pretty=oneline A...B

>bbbbbbb... 3rd on b
>bbbbbbb... 2nd on b
<aaaaaaa... 3rd on a
<aaaaaaa... 2nd on a
-yyyyyyy... 1st on b
-xxxxxxx... 1st on a

Not the < and > turning into arrows, I can't ๐Ÿ˜ญ it's giving annotated map.

  • --graph โ€” draw a text-based graphical representation of the commit history on the left hand side of the output. This may cause extra lines to be printed in between commits, in order for the graph history to be drawn properly. Cannot be combined with --no-walk โ€” those two do NOT sit together at lunch, periodt.

This enables parent rewriting, see History Simplification above.

This implies the --topo-order option by default, but the --date-order option may also be specified. So it picks a fave but you're allowed to swap.

  • --show-linear-break[=<barrier>] โ€” when --graph is not used, all history branches are flattened which can make it hard to see that the two consecutive commits do not belong to a linear branch. This option puts a barrier in between them in that case. If <barrier> is specified, it is the string that will be shown instead of the default one. Custom barrier string?? main character energy honestly.
  • --graph-lane-limit=<n> โ€” when --graph is used, limit the number of graph lanes to be shown. Lanes over the limit are replaced with a truncation mark ~. By default it is set to 0 (no limit), zero and negative values are ignored and treated as no limit. So yeah, 0 and the negatives are all just "no limit", don't overthink it ๐Ÿงš
  • --no-graph-indent, --graph-indent โ€” when used with --graph, indent visual roots (commits with no parents or whose parents are not shown) to differentiate them from commits that are vertically adjacent but unrelated. Enabled by default. Use --no-graph-indent to disable or set log.graphIndent to set a default preference. The roots get their own little space, as they deserve ๐Ÿ‘‘

๐ŸŒธ PRETTY FORMATS ๐ŸŒธ

Ok so if the commit is a merge, and if the pretty-format is not oneline, email or raw, an additional line is inserted before the Author: line. This line begins with "Merge: " and the hashes of ancestral commits are printed, separated by spaces. Big caveat bestie: note that the listed commits may not necessarily be the list of the direct parent commits if you have limited your view of history โ€” for example, if you are only interested in changes related to a certain directory or file. So like, don't @ me when the list looks weird, it's doing what you asked.

There are several built-in formats, and you can define additional formats by setting a pretty.<name> config option to either another format name, or a format: string, as described below (see git-config(1)). Here are the details of the built-in formats, get comfy:

oneline

<hash> <title-line>

This is designed to be as compact as possible. Snack-sized. A little bite.

short

commit <hash>
Author: <author>

    <title-line>

medium

commit <hash>
Author: <author>
Date:   <author-date>

    <title-line>

    <full-commit-message>

full

commit <hash>
Author: <author>
Commit: <committer>

    <title-line>

    <full-commit-message>

fuller

commit <hash>
Author:     <author>
AuthorDate: <author-date>
Commit:     <committer>
CommitDate: <committer-date>

     <title-line>

     <full-commit-message>

reference

<abbrev-hash> (<title-line>, <short-author-date>)

This format is used to refer to another commit in a commit message and is the same as --pretty='format:%C(auto)%h (%s, %ad)'. By default, the date is formatted with --date=short unless another --date option is explicitly specified. As with any format: with format placeholders, its output is not affected by other options like --decorate and --walk-reflogs. It minds its own business, respectfully ๐Ÿ’…

email

From <hash> <date>
From: <author>
Date: <author-date>
Subject: [PATCH] <title-line>

<full-commit-message>

mboxrd

Like email, but lines in the commit message starting with "From " (preceded by zero or more ">") are quoted with ">" so they aren't confused as starting a new commit. Escaping the imposters, we love to see it ๐ŸŽ€

raw

The raw format shows the entire commit exactly as stored in the commit object. Notably, the hashes are displayed in full, regardless of whether --abbrev or --no-abbrev are used, and parents information show the true parent commits, without taking grafts or history simplification into account. Note that this format affects the way commits are displayed, but not the way the diff is shown e.g. with git log --raw. To get full object names in a raw diff format, use --no-abbrev. No filter, no edits, just the truth โœจ

format:<format-string>

The format:<format-string> format allows you to specify which information you want to show. It works a little bit like printf format, with the notable exception that you get a newline with %n instead of \n. That trips everyone up, so like, noted ๐Ÿ“

E.g, format:"The author of %h was %an, %ar%nThe title was >>%s<<%n" would show something like this:

The author of fe6e0ee was Junio C Hamano, 23 hours ago
The title was >>t4119: test autocomputing -p<n> for traditional diff input.<<

The placeholders are:

  • Placeholders that expand to a single literal character:
    • %n โ€” newline
    • %% โ€” a raw %
    • %x00 โ€” %x followed by two hexadecimal digits is replaced with a byte with the hexadecimal digits' value (we will call this "literal formatting code" in the rest of this document).
  • Placeholders that affect formatting of later placeholders:
    • %Cred โ€” switch color to red
    • %Cgreen โ€” switch color to green
    • %Cblue โ€” switch color to blue
    • %Creset โ€” reset color
    • %C(<spec>) โ€” color specification, as described under Values in the "CONFIGURATION FILE" section of git-config(1). By default, colors are shown only when enabled for log output (by color.diff, color.ui, or --color, and respecting the auto settings of the former if we are going to a terminal). %C(auto,<spec>) is accepted as a historical synonym for the default (e.g., %C(auto,red)). Specifying %C(always,<spec>) will show the colors even when color is not otherwise enabled (though consider just using --color=always to enable color for the whole output, including this format and anything else git might color). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.
    • %m โ€” left (<), right (>) or boundary (-) mark
    • %w([<w>[,<i1>[,<i2>]]]) โ€” switch line wrapping, like the -w option of git-shortlog(1).

okay so the padding girlies deserve their own moment because this is where your format string starts doing architecture ๐Ÿ’…โœจ

  • %<(<n>[,(trunc|ltrunc|mtrunc)]) โ€” makes the next placeholder take at least <n> column widths, padding spaces on the right if it needs to. Optionally you can truncate (with an ellipsis ..) at the left (ltrunc) giving you ..ft, in the middle (mtrunc) giving you mi..le, or at the end (trunc) giving you rig.., whenever the output is longer than <n> columns. Note 1: truncating only works correctly when <n> >= 2. Note 2: spaces around the <n> and <m> (see below) values are optional. Note 3: emojis and other wide characters take two display columns, which may over-run column boundaries (yes, the irony of an emoji breaking your alignment is not lost on me ๐Ÿ˜ญ). Note 4: decomposed character combining marks may be misplaced at padding boundaries.
  • %<|(<m> ) โ€” makes the next placeholder take at least up to the <m>th display column, padding spaces on the right if necessary. Negative <m> values measure column positions from the right hand edge of the terminal window.
  • %>(<n>), %>|(<m>) โ€” same energy as %<(<n>) and %<|(<m>) respectively, but padding spaces on the left instead.
  • %>>(<n>), %>>|(<m>) โ€” same as %>(<n>) and %>|(<m>) respectively, except that if the next placeholder takes more spaces than given and there are spaces on its left, it uses those spaces instead.
  • %><(<n>), %><|(<m>) โ€” same as %<(<n>) and %<|(<m>) respectively, but it pads both sides, i.e. the text is centered. main character alignment, honestly ๐ŸŽ€

โœจ placeholders that expand to info extracted from the commit โœจ

this is the good stuff, buckle up bestie ๐Ÿซถ

  • %H โ€” commit hash
  • %h โ€” abbreviated commit hash
  • %T โ€” tree hash
  • %t โ€” abbreviated tree hash
  • %P โ€” parent hashes
  • %p โ€” abbreviated parent hashes
  • %an โ€” author name
  • %aN โ€” author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %ae โ€” author email
  • %aE โ€” author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %al โ€” author email local-part (the part before the @ sign)
  • %aL โ€” author local-part (see %al) respecting .mailmap, see git-shortlog(1) or git-blame(1)
  • %ad โ€” author date (format respects the --date= option)
  • %aD โ€” author date, RFC2822 style
  • %ar โ€” author date, relative
  • %at โ€” author date, UNIX timestamp
  • %ai โ€” author date, ISO 8601-like format
  • %aI โ€” author date, strict ISO 8601 format
  • %as โ€” author date, short format (YYYY-MM-DD)
  • %ah โ€” author date, human style (like the --date=human option of git-rev-list(1))
  • %cn โ€” committer name
  • %cN โ€” committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %ce โ€” committer email
  • %cE โ€” committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %cl โ€” committer email local-part (the part before the @ sign)
  • %cL โ€” committer local-part (see %cl) respecting .mailmap, see git-shortlog(1) or git-blame(1)
  • %cd โ€” committer date (format respects the --date= option)
  • %cD โ€” committer date, RFC2822 style
  • %cr โ€” committer date, relative
  • %ct โ€” committer date, UNIX timestamp
  • %ci โ€” committer date, ISO 8601-like format
  • %cI โ€” committer date, strict ISO 8601 format
  • %cs โ€” committer date, short format (YYYY-MM-DD)
  • %ch โ€” committer date, human style (like the --date=human option of git-rev-list(1))
  • %d โ€” ref names, like the --decorate option of git-log(1)
  • %D โ€” ref names without the " (" and ")" wrapping
  • %(count) โ€” the number of a patch within a patch series. Used only in --commit-list-format in format-patch
  • %(total) โ€” the total number of patches in a patch series. Used only in --commit-list-format in format-patch

the fancy custom ones ๐Ÿ’…

  • %(decorate[:<option>,...]) โ€” ref names with custom decorations. The decorate string may be followed by a colon and zero or more comma-separated options. Option values may contain literal formatting codes โ€” and those must be used for commas (%x2C) and closing parentheses (%x29), because of their role in the option syntax. iykyk ๐Ÿ™ˆ
    • prefix=<value> โ€” shown before the list of ref names. Defaults to " (".
    • suffix=<value> โ€” shown after the list of ref names. Defaults to ")".
    • separator=<value> โ€” shown between ref names. Defaults to ", ".
    • pointer=<value> โ€” shown between HEAD and the branch it points to, if any. Defaults to " โ†’ ".
    • tag=<value> โ€” shown before tag names. Defaults to "tag: ".

For example, to produce decorations with no wrapping or tag annotations, and spaces as separators:

%(decorate:prefix=,suffix=,tag=,separator= )
  • %(describe[:<option>,...]) โ€” human-readable name, like git-describe(1); empty string for commits that can't be described. The describe string may be followed by a colon and zero or more comma-separated options. Heads up: descriptions can be inconsistent when tags are added or removed at the same time. ๐Ÿ˜ฌ
    • tags[=<bool-value>] โ€” instead of only considering annotated tags, consider lightweight tags as well.
    • abbrev=<number> โ€” instead of using the default number of hexadecimal digits (which varies according to the number of objects in the repository, with a default of 7), use <number> digits โ€” or as many digits as needed to form a unique object name.
    • match=<pattern> โ€” only consider tags matching the given glob(7) <pattern>, excluding the refs/tags/ prefix.
    • exclude=<pattern> โ€” do not consider tags matching the given glob(7) <pattern>, excluding the refs/tags/ prefix.

  • %S โ€” ref name given on the command line by which the commit was reached (like git log --source), only works with git log
  • %e โ€” encoding
  • %s โ€” subject
  • %f โ€” sanitized subject line, suitable for a filename
  • %b โ€” body
  • %B โ€” raw body (unwrapped subject and body)
  • %N โ€” commit notes
  • %GG โ€” raw verification message from GPG for a signed commit
  • %G? โ€” shows "G" for a good (valid) signature, "B" for a bad signature, "U" for a good signature with unknown validity, "X" for a good signature that has expired, "Y" for a good signature made by an expired key, "R" for a good signature made by a revoked key, "E" if the signature cannot be checked (e.g. missing key) and "N" for no signature
  • %GS โ€” shows the name of the signer for a signed commit
  • %GK โ€” shows the key used to sign a signed commit
  • %GF โ€” shows the fingerprint of the key used to sign a signed commit
  • %GP โ€” shows the fingerprint of the primary key whose subkey was used to sign a signed commit
  • %GT โ€” shows the trust level for the key used to sign a signed commit

reflog besties ๐Ÿงš

  • %gD โ€” reflog selector, e.g. refs/stash@{1} or refs/stash@{2 minutes ago}; the format follows the rules described for the -g option. The portion before the @ is the refname as given on the command line (so git log -g refs/heads/master would yield refs/heads/master@{0}).
  • %gd โ€” shortened reflog selector; same as %gD, but the refname portion is shortened for human readability (so refs/heads/master becomes just master).
  • %gn โ€” reflog identity name
  • %gN โ€” reflog identity name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %ge โ€” reflog identity email
  • %gE โ€” reflog identity email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
  • %gs โ€” reflog subject

  • %(trailers[:<option>,...]) โ€” display the trailers of the body as interpreted by git-interpret-trailers(1). The trailers string may be followed by a colon and zero or more comma-separated options. If any option is provided multiple times, the last occurrence wins. ๐Ÿ‘‘
    • key=<key> โ€” only show trailers with the specified <key>. Matching is done case-insensitively and the trailing colon is optional. If the option is given multiple times, trailer lines matching any of the keys are shown. This option automatically enables the only option so that non-trailer lines in the trailer block are hidden. If that's not what you want, it can be disabled with only=false. E.g., %(trailers:key=Reviewed-by) shows trailer lines with key Reviewed-by.
    • only[=<bool>] โ€” select whether non-trailer lines from the trailer block should be included.

okay so %(trailers:...) has its own little options menu, and here is every single knob on it, no skips:

  • separator=<sep> โ€” specify the separator inserted between trailer lines. Defaults to a line feed character. The string <sep> may contain the literal formatting codes described above. To use comma as separator one must use %x2C as it would otherwise be parsed as next option. E.g., %(trailers:key=Ticket,separator=%x2C ) shows all trailer lines whose key is Ticket separated by a comma and a space.
  • unfold[=<bool>] โ€” make it behave as if interpret-trailer's --unfold option was given. E.g., %(trailers:only,unfold=true) unfolds and shows all trailer lines.
  • keyonly[=<bool>] โ€” only show the key part of the trailer.
  • valueonly[=<bool>] โ€” only show the value part of the trailer.
  • key_value_separator=<sep> โ€” specify the separator inserted between the key and value of each trailer. Defaults to ": ". Otherwise it shares the same semantics as separator=<sep> above.
Note ๐Ÿซถ Some placeholders may depend on other options given to the revision traversal engine. For example, the %g* reflog options will insert an empty string unless we are traversing reflog entries (e.g., by git log -g). The %d and %D placeholders will use the "short" decoration format if --decorate was not already provided on the command line.

The boolean options accept an optional value [=<bool-value>]. The values taken by --type=bool git-config(1), like yes and off, are all accepted. Giving a boolean option without =<value> is equivalent to giving it with =true. easy โœจ

And now, the modifier era โ€” these tiny characters after the % are so underrated:

  • If you add a + (plus sign) after % of a placeholder, a line-feed is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.
  • If you add a - (minus sign) after % of a placeholder, all consecutive line-feeds immediately preceding the expansion are deleted if and only if the placeholder expands to an empty string.
  • If you add a ' ' (space) after % of a placeholder, a space is inserted immediately before the expansion if and only if the placeholder expands to a non-empty string.

๐Ÿฆ‹ tformat: ๐Ÿฆ‹

The tformat: format works exactly like format:, except that it provides "terminator" semantics instead of "separator" semantics. In other words, each commit has the message terminator character (usually a newline) appended, rather than a separator placed between entries. This means that the final entry of a single-line format will be properly terminated with a new line, just as the "oneline" format does. For example:

$ git log -2 --pretty=format:%h 4da45bef \
  | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
4da45be
7134973 -- NO NEWLINE

$ git log -2 --pretty=tformat:%h 4da45bef \
  | perl -pe '$_ .= " -- NO NEWLINE\n" unless /\n/'
4da45be
7134973

In addition, any unrecognized string that has a % in it is interpreted as if it has tformat: in front of it. For example, these two are equivalent:

$ git log -2 --pretty=tformat:%h 4da45bef
$ git log -2 --pretty=%h 4da45bef

๐Ÿ’… DIFF FORMATTING ๐Ÿ’…

By default, git log does not generate any diff output. The options below can be used to show the changes made by each commit. that's your glow-up switch ๐Ÿ’–

Note that unless one of --diff-merges variants (including short -m, -c, --cc, and --dd options) is explicitly given, merge commits will not show a diff, even if a diff format like --patch is selected, nor will they match search options like -S. The exception is when --first-parent is in use, in which case first-parent is the default format for merge commits. ๐Ÿ˜ญ read that twice bestie, it's the classic gotcha.
  • -p, -u, --patch โ€” Generate patch (see the section called โ€œGENERATING PATCH TEXT WITH -Pโ€).
  • -s, --no-patch โ€” Suppress all output from the diff machinery. Useful for commands like git show that show the patch by default to squelch their output, or to cancel the effect of options like --patch, --stat earlier on the command line in an alias.
  • -m โ€” Show diffs for merge commits in the default format. This is similar to --diff-merges=on, except -m will produce no output unless -p is given as well.
  • -c โ€” Produce combined diff output for merge commits. Shortcut for --diff-merges=combined -p.
  • --cc โ€” Produce dense combined diff output for merge commits. Shortcut for --diff-merges=dense-combined -p.
  • --dd โ€” Produce diff with respect to first parent for both merge and regular commits. Shortcut for --diff-merges=first-parent -p.
  • --remerge-diff โ€” Produce remerge-diff output for merge commits. Shortcut for --diff-merges=remerge -p.
  • --no-diff-merges โ€” Synonym for --diff-merges=off.

๐ŸŒˆ --diff-merges=<format> ๐ŸŒˆ

Specify diff format to be used for merge commits. Default is f unless --first-parent is in use, in which case first-parent is the default.

The following formats are supported:

  • off, none โ€” Disable output of diffs for merge commits. Useful to override implied value.
  • on, m โ€” Make diff output for merge commits to be shown in the default format. The default format can be changed using log.diffMerges configuration variable, whose default value is separate.
  • first-parent, 1 โ€” Show full diff with respect to first parent. This is the same format as --patch produces for non-merge commits.
  • separate โ€” Show full diff with respect to each of parents. Separate log entry and diff is generated for each parent.
  • combined, c โ€” Show differences from each of the parents to the merge result simultaneously instead of showing pairwise diff between a parent and the result one at a time. Furthermore, it lists only files which were modified from all parents.
  • dense-combined, cc โ€” Further compress output produced by --diff-merges=combined by omitting uninteresting hunks whose contents in the parents have only two variants and the merge result picks one of them without modification.
  • remerge, r โ€” Remerge two-parent merge commits to create a temporary tree objectโ€”potentially containing files with conflict markers and such. A diff is then shown between that temporary tree and the actual merge commit.
โš ๏ธ The output emitted when this option is used is subject to change, and so is its interaction with other options (unless explicitly documented). So likeโ€ฆ don't build your whole personality on it, iykyk ๐Ÿ™ˆ

  • --combined-all-paths โ€” Cause combined diffs (used for merge commits) to list the name of the file from all parents. It thus only has effect when --diff-merges=[dense-]combined is in use, and is likely only useful if filename changes are detected (i.e. when either rename or copy detection have been requested).
  • -U<n>, --unified=<n> โ€” Generate diffs with <n> lines of context. The number of context lines defaults to diff.context or 3 if the configuration variable is unset. (-U without <n> is silently accepted as a synonym for -p due to a historical accident). Implies --patch. historical accident ๐Ÿ’€ iconic honestly
  • --output=<file> โ€” Output to a specific file instead of stdout.
  • --output-indicator-new=<char>, --output-indicator-old=<char>, --output-indicator-context=<char> โ€” Specify the character used to indicate new, old or context lines in the generated patch. Normally they are +, - and ' ' respectively.
  • --raw โ€” For each commit, show a summary of changes using the raw diff format. See the โ€œRAW OUTPUT FORMATโ€ section of git-diff(1). This is different from showing the log itself in raw format, which you can achieve with --format=raw.
  • --patch-with-raw โ€” Synonym for -p --raw.
  • -t โ€” Show the tree objects in the diff output.
  • --indent-heuristic โ€” Enable the heuristic that shifts diff hunk boundaries to make patches easier to read. This is the default. ๐ŸŽ€
  • --no-indent-heuristic โ€” Disable the indent heuristic.
  • --minimal โ€” Spend extra time to make sure the smallest possible diff is produced.
  • --patience โ€” Generate a diff using the โ€œpatience diffโ€ algorithm.
  • --histogram โ€” Generate a diff using the โ€œhistogram diffโ€ algorithm.
  • --anchored=<text> โ€” Generate a diff using the โ€œanchored diffโ€ algorithm.

This option may be specified more than once.

If a line exists in both the source and destination, exists only once, and starts with <text>, this algorithm attempts to prevent it from appearing as a deletion or addition in the output. It uses the โ€œpatience diffโ€ algorithm internally. it's giving main character energy for one specific line โœจ

๐Ÿงš --diff-algorithm=(patience|minimal|histogram|myers) ๐Ÿงš

Choose a diff algorithm. The variants are as follows:

  • default, myers โ€” The basic greedy diff algorithm. Currently, this is the default.
  • minimal โ€” Spend extra time to make sure the smallest possible diff is produced.
  • patience โ€” Use โ€œpatience diffโ€ algorithm when generating patches.
  • histogram โ€” This algorithm extends the patience algorithm to โ€œsupport low-occurrence common elementsโ€.

For instance, if you configured the diff.algorithm variable to a non-default value and want to use the default one, then you have to use --diff-algorithm=default option. the config does NOT care about your feelings ๐Ÿ˜ญ

โญ --stat[=<width>[,<name-width>[,<count>]]] โญ

Generate a diffstat. By default, as much space as necessary will be used for the filename part, and the rest for the graph part. Maximum width defaults to terminal width, or 80 columns if not connected to a terminal, and can be overridden by <width>. The width of the filename part can be limited by giving another width <name-width> after a comma or by setting diff.statNameWidth=<name-width>. The width of the graph part can be limited by using --stat-graph-width=<graph-width> or by setting diff.statGraphWidth=<graph-width>. Using --stat or --stat-graph-width affects all commands generating a stat graph, while setting diff.statNameWidth or diff.statGraphWidth does not affect git format-patch. By giving a third parameter <count>, you can limit the output to the first <count> lines, followed by ... if there are more. numbers!! widths!! the whole buffet ๐Ÿ“

  • --stat-width=<width>, --stat-name-width=<name-width>, --stat-count=<count> โ€” the same three knobs, but you can totally set each one individually instead of doing the whole <width>,<name-width>,<count> combo platter ๐ŸŽ›๏ธ

  • --compact-summary โ€” gives you a condensed lil summary of the extended header tea โ€” file creations or deletions (shown as "new" or "gone", and optionally +l if it's a symlink ๐Ÿ‘€) plus mode changes (+x or -x for adding or removing the executable bit respectively) โ€” all stuffed into the diffstat. It lands right between the filename part and the graph part. Also, heads up: this implies --stat โœจ
  • --numstat โ€” basically --stat's cousin, except it shows the number of added and deleted lines in decimal notation and the pathname with no abbreviation, so it's way more machine-friendly ๐Ÿค–. And for binary files? It just spits out two - instead of saying 0 0. iconic.
  • --shortstat โ€” only wants the last line of the --stat format, bestie. That's the total number of modified files, plus how many lines got added and deleted. Short and sweet ๐Ÿ’…
  • -X [<param>,...], --dirstat[=<param>,...] โ€” shows you the distribution of the relative amount of changes for each sub-directory ๐Ÿ—‚๏ธ. You can customize how --dirstat behaves by passing it a comma-separated list of parameters. The defaults are controlled by the diff.dirstat config variable (peep git-config(1)). Here's the menu of parameters:
    • changes โ€” computes the dirstat numbers by counting the lines removed from the source, or added to the destination. This ignores the amount of pure code movement inside a file โ€” like, rearranging lines in a file doesn't count as much as other changes. This is the default behavior when you give no parameter at all.
    • lines โ€” computes the dirstat numbers by doing the regular line-based diff analysis and summing up the removed/added line counts. (For binary files it counts 64-byte chunks instead, since binary files have no natural concept of lines, obviously ๐Ÿซ ). This is a more expensive --dirstat behavior than changes, but it does count rearranged lines within a file as much as other changes. The resulting output is consistent with what you get from the other --*stat options.
    • files โ€” computes the dirstat numbers by counting the number of files changed. Every changed file counts equally in the dirstat analysis. This is the computationally cheapest --dirstat behavior, since it doesn't have to look at the file contents at all. lazy girl summer behavior and honestly? valid.
    • cumulative โ€” counts changes in a child directory for the parent directory too. โš ๏ธ Note that when you use cumulative, the sum of the percentages reported may exceed 100%. The default (non-cumulative) behavior can be specified with the noncumulative parameter.
    • <limit> โ€” an integer parameter that specifies a cut-off percent (3% by default). Directories contributing less than this percentage of the changes simply don't show up in the output. gone girl, not invited.

Example time ๐ŸŽ€ โ€” the following will count changed files, while ignoring directories with less than 10% of the total amount of changed files, and accumulating child directory counts in the parent directories:

--dirstat=files,10,cumulative
  • --cumulative โ€” a synonym for --dirstat=cumulative. short king.
  • --dirstat-by-file[=<param>,...] โ€” a synonym for --dirstat=files,<param>,.... also short king.
  • --summary โ€” outputs a condensed summary of extended header info such as creations, renames and mode changes ๐Ÿ“
  • --patch-with-stat โ€” a synonym for -p --stat. yes that's it, that's the whole vibe.
  • -z โ€” separates the commits with NULs instead of newlines ๐Ÿซถ

Also, when --raw or --numstat has been given, it does not munge pathnames and uses NULs as output field terminators.

Without this option, pathnames with "unusual" characters get quoted, as explained for the config variable core.quotePath (see git-config(1)).

  • --name-only โ€” shows only the name of each changed file in the post-image tree. The file names are often encoded in UTF-8. For more info, see the discussion about encoding in the git-log(1) manual page ๐Ÿ“›
  • --name-status โ€” shows only the name(s) and status of each changed file. See the description of the --diff-filter option for what those status letters actually mean. Just like --name-only, the file names are often encoded in UTF-8 ๐Ÿท๏ธ
  • --submodule[=<format>] โ€” tells Git how to show differences in submodules. When you specify --submodule=short, the short format is used โ€” it just shows the names of the commits at the beginning and end of the range. When you specify --submodule or --submodule=log, the log format is used, which lists the commits in the range like git-submodule(1) summary does. And when you specify --submodule=diff, the diff format is used โ€” it shows an inline diff of the changes in the submodule contents between the commit range ๐Ÿ˜ฎโ€๐Ÿ’จ. Defaults to diff.submodule, or the short format if that config option isn't set.
  • --color[=<when>] โ€” show colored diff ๐ŸŒˆ. --color (i.e. without =<when>) is the same as --color=always. <when> can be one of always, never, or auto.
  • --no-color โ€” turns off colored diff entirely. It's the same as --color=never ๐Ÿ’€
  • --color-moved[=<mode>] โ€” moved lines of code get colored differently โœจ. The <mode> defaults to no if you don't give the option at all, and to zebra if you give the option with no mode. The mode must be one of:
    • no โ€” moved lines are not highlighted. boring but honest.
    • default โ€” a synonym for zebra. โš ๏ธ This may change to a more sensible mode in the future, so don't get too attached.
    • plain โ€” any line added in one location and removed in another location gets colored with color.diff.newMoved. Similarly, color.diff.oldMoved is used for removed lines that are added somewhere else in the diff. This mode picks up any moved line, but ngl it's not super useful in a review when you're trying to figure out if a block of code was moved without permutation.
    • blocks โ€” blocks of moved text of at least 20 alphanumeric characters are detected greedily ๐Ÿ‘€. The detected blocks are painted using either the color.diff.(old|new)Moved color. Fair warning: adjacent blocks cannot be told apart.
    • zebra โ€” blocks of moved text are detected as in blocks mode. The blocks are painted using either the color.diff.(old|new)Moved color or color.diff.(old|new)MovedAlternative. The change between the two colors indicates that a new block was detected ๐Ÿฆ“
    • dimmed-zebra โ€” similar to zebra, but with additional dimming of the uninteresting parts of moved code. The bordering lines of two adjacent blocks are considered interesting, the rest is uninteresting. Also dimmed_zebra is a deprecated synonym โ€” old news, bestie.
  • --no-color-moved โ€” turns off move detection. You can use this to override configuration settings. It's the same as --color-moved=no ๐Ÿ™…โ€โ™€๏ธ
  • --color-moved-ws=<mode>,... โ€” configures how whitespace is ignored when performing move detection for --color-moved. These modes can be given as a comma-separated list:
    • no โ€” do not ignore whitespace when performing move detection.
    • ignore-space-at-eol โ€” ignore changes in whitespace at EOL.
    • ignore-space-change โ€” ignore changes in the amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.
    • ignore-all-space โ€” ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.
    • allow-indentation-change โ€” initially ignore any whitespace in the move detection, then group the moved code blocks into a block only if the change in whitespace is the same per line. โš ๏ธ This is incompatible with the other modes, so pick a lane.
  • --no-color-moved-ws โ€” do not ignore whitespace when performing move detection. You can use this to override configuration settings. It's the same as --color-moved-ws=no ๐Ÿšซ
  • --word-diff[=<mode>] โ€” by default, words are delimited by whitespace; see --word-diff-regex below. The <mode> defaults to plain, and must be one of:
    • color โ€” highlight changed words using only colors. Implies --color ๐ŸŽจ
    • plain โ€” show words as [-removed-] and {added}. It makes no attempts to escape the delimiters if they appear in the input, so the output may be ambiguous ๐Ÿ˜ญ
    • porcelain โ€” use a special line-based format intended for script consumption. Added/removed/unchanged runs are printed in the usual unified diff format, starting with a +, -, or character at the beginning of the line and extending to the end of the line. Newlines in the input are represented by a tilde ~ on a line of its own.
    • none โ€” disable word diff again. we're so back / we're so done.

Note that despite the name of the first mode, color is used to highlight the changed parts in all modes if enabled ๐ŸŒˆ

The --word-diff option operates by taking the same line-by-line diff that's produced without the option, and computing word-by-word changes within each hunk. This may produce a larger diff than a dedicated word-diff tool would ๐Ÿซ . If Git acquires a different implementation in the future, the output may change. Note that this is similar to the --diff-algorithm option, which may also change the output. iykyk.

  • --word-diff-regex=<regex> โ€” use <regex> to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies --word-diff unless it was already enabled.

Every non-overlapping match of the <regex> is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append |[^[:space:]] to your regular expression to make sure it matches all non-whitespace characters. โš ๏ธ A match that contains a newline is silently truncated(!) at the newline โ€” sneaky.

For example, --word-diff-regex=. will treat each character as a word and, correspondingly, show differences character by character ๐Ÿ‘‘.

The regex can also be set via a diff driver or configuration option โ€” see gitattributes(5) or git-config(1). Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings. hierarchy matters, bestie ๐Ÿ’…

  • --color-words[=<regex>] โ€” equivalent to --word-diff=color plus (if a regex was specified) --word-diff-regex=<regex> โœจ
  • --no-renames โ€” bestie, this one just turns rename detection off. Like fully off, even if your config file is like "no babe default to detecting renames". Nope. Not today. ๐Ÿ’…
  • --rename-empty, --no-rename-empty โ€” controls whether empty blobs are allowed to be used as a rename source. That's it, that's the whole vibe check. โœจ
  • --check โ€” this one's your lil safety bestie ๐Ÿซถ โ€” it warns you if your changes introduce conflict markers or whitespace errors. And what counts as a "whitespace error"? That's controlled by the core.whitespace configuration. By default the culprits are: trailing whitespaces (including lines that are nothing but whitespace ๐Ÿ˜ญ) and a space character that's immediately followed by a tab character inside the initial indent of the line. If it finds problems it exits with a non-zero status. Also heads up: it's not compatible with --exit-code, so don't try to serve both at once.
  • --ws-error-highlight=<kind> โ€” highlights whitespace errors in the context, old or new lines of the diff. Multiple values get separated by comma, none resets previous values, default resets the list to new, and all is shorthand for old,new,context. When you don't pass this option and diff.wsErrorHighlight config isn't set either, only whitespace errors in new lines get highlighted. The errors get colored with color.diff.whitespace ๐ŸŒˆ
  • --full-index โ€” instead of showing just the first handful of characters, this shows the full pre- and post-image blob object names on the index line when it's generating patch format output. No abbreviating, we're showing the whole thing, periodt.
  • --binary โ€” on top of --full-index, this outputs a binary diff that can actually be applied with git-apply. Implies --patch. ๐Ÿ”ฅ
  • --abbrev[=<n>] โ€” instead of showing the full 40-byte hexadecimal object name in diff-raw format output and diff-tree header lines, show the shortest prefix that's at least <n> hexdigits long that uniquely refers to the object. In diff-patch output format though, --full-index takes higher precedence โ€” i.e. if --full-index is specified, full blob names get shown regardless of --abbrev. Non default number of digits can be specified with --abbrev=<n>.
  • -B[<n>][/<m>], --break-rewrites[=[<n>][/<m>]] โ€” this breaks complete rewrite changes into pairs of delete and create. It serves two purposes, bestie:

It affects the way a change that amounts to a total rewrite of a file โ€” not as a series of deletion and insertion mixed together with a very few lines that happen to match textually as the context, but as a single deletion of everything old followed by a single insertion of everything new. The number <m> controls this aspect of the -B option (defaults to 60%). -B/70% specifies that less than 30% of the original should remain in the result for Git to consider it a total rewrite (i.e. otherwise the resulting patch will be a series of deletion and insertion mixed together with context lines).

When used with -M, a totally-rewritten file is also considered as the source of a rename (usually -M only considers a file that disappeared as the source of a rename), and the number <n> controls this aspect of the -B option (defaults to 50%). -B20% specifies that a change with addition and deletion compared to 20% or more of the file's size are eligible for being picked up as a possible source of a rename to another file. ๐ŸŽ€

  • -M[<n>], --find-renames[=<n>] โ€” if it's generating diffs, this detects and reports renames for each commit. For following files across renames while traversing history, see --follow (different tool, different vibe). If <n> is specified, it's a threshold on the similarity index (i.e. amount of addition/deletions compared to the file's size). For example, -M90% means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn't changed. Without a % sign, the number gets read as a fraction, with a decimal point before it. I.e. -M5 becomes 0.5, and is thus the same as -M50%. Similarly, -M05 is the same as -M5%. To limit detection to exact renames, use -M100%. The default similarity index is 50%. โœจ
  • -C[<n>], --find-copies[=<n>] โ€” detects copies as well as renames. See also --find-copies-harder. If <n> is specified, it has the same meaning as for -M<n>.
  • --find-copies-harder โ€” okay so for performance reasons, by default the -C option only finds copies if the original file of the copy was modified in the same changeset. This flag makes the command inspect unmodified files as candidates for the source of copy. Heads up though: this is a very expensive operation for large projects, so use it with caution ๐Ÿ˜ญ Giving more than one -C option has the same effect.
  • -D, --irreversible-delete โ€” omits the preimage for deletes, i.e. it prints only the header but not the diff between the preimage and /dev/null.
The resulting patch is not meant to be applied with patch or git apply โ€” this is solely for people who want to just concentrate on reviewing the text after the change. In addition, the output obviously lacks enough information to apply such a patch in reverse, even manually, hence the name of the option. ๐Ÿ’€

When used together with -B, it also omits the preimage in the deletion part of a delete/create pair.

  • -l<num> โ€” so the -M and -C options involve some preliminary steps that can detect subsets of renames/copies cheaply, followed by an exhaustive fallback portion that compares all remaining unpaired destinations to all relevant sources. (For renames, only remaining unpaired sources are relevant; for copies, all original sources are relevant.) For N sources and destinations, this exhaustive check is O(N^2). This option prevents that exhaustive portion of rename/copy detection from running if the number of source/destination files involved exceeds the specified number. Defaults to diff.renameLimit. Note that a value of 0 is treated as unlimited.
  • --diff-filter=[(A|C|D|M|R|T|U|X|B)...[*]] โ€” selects only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their Type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are UnknowX (X... okay it's Unknown ๐Ÿ˜ญ), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used. When * (All-or-none) is added to the combination, all paths are selected if there is any file that matches other criteria in the comparison; if there is no file that matches other criteria, nothing is selected.

Also, these upper-case letters can be downcased to exclude. E.g. --diff-filter=ad excludes added and deleted paths. ๐Ÿ™ˆ

Note that not all diffs can feature all types. For instance, copied and renamed entries cannot appear if detection for those types is disabled.

  • -S<string> โ€” looks for differences that change the number of occurrences of the specified <string> (i.e. addition/deletion) in a file. Intended for the scripter's use. ๐Ÿงš

It's useful when you're looking for an exact block of code (like a struct), and want to know the history of that block since it first came into being: use the feature iteratively to feed the interesting block in the preimage back into -S, and keep going until you get the very first version of the block.

Binary files are searched as well. ๐Ÿ‘‘

  • -G<regex> โ€” looks for differences whose patch text contains added/removed lines that match <regex>.

To illustrate the difference between -S<regex> --pickaxe-regex and -G<regex>, consider a commit with the following diff in the same file:

    +    return frotz(nitfol, two->ptr, 1, 0);
    ...
    -    hit = frotz(nitfol, mf2.ptr, 1, 0);

While git log -G"frotz\(nitfol" will show this commit, git log -S"frotz\(nitfol" --pickaxe-regex will not (because the number of occurrences of that string did not change). ๐Ÿ’€

Unless --text is supplied, patches of binary files without a textconv filter will be ignored.

See the pickaxe entry in gitdiffcore(7) for more information.

  • --find-object=<object-id> โ€” looks for differences that change the number of occurrences of the specified object. Similar to -S, just the argument is different in that it doesn't search for a specific string but for a specific object id.

The object can be a blob or a submodule commit. It implies the -t option in git-log to also find trees. ๐ŸŒธ

  • --pickaxe-all โ€” when -S or -G finds a change, this shows all the changes in that changeset, not just the files that contain the change in <string>. Main character energy for the whole commit. ๐Ÿ’…
  • --pickaxe-regex โ€” treats the <string> given to -S as an extended POSIX regular expression to match.
  • -O<orderfile> โ€” controls the order in which files appear in the output. This overrides the diff.orderFile configuration variable (see git-config(1)). To cancel diff.orderFile, use -O/dev/null. ๐ŸŽ€

The output order is determined by the order of glob patterns in <orderfile>. All files with pathnames that match the first pattern are output first, all files with pathnames that match the second pattern (but not the first) are output next, and so on. All files with pathnames that do not match any pattern are output last, as if there was an implicit match-all pattern at the end of the file. If multiple pathnames have the same rank (they match the same pattern but no earlier patterns), their output order relative to each other is the normal order.

<orderfile> is parsed as follows:

  • Blank lines are ignored, so they can be used as separators for readability.
  • Lines starting with a hash ("#") are ignored, so they can be used for comments. Add a backslash ("\") to the beginning of the pattern if it starts with a hash.
  • Each other line contains a single pattern.

Patterns have the same syntax and semantics as patterns used for fnmatch(3) without the FNM_PATHNAME flag, except a pathname also matches a pattern if removing any number of the final pathname components matches the pattern. For example, the pattern "foo*bar" matches "fooasdfbar" and "foo/bar/baz/asdf" but not "foobarx". ๐Ÿฆ‹

  • --skip-to=<file>, --rotate-to=<file> โ€” discards the files before the named <file> from the output (i.e. skip to), or moves them to the end of the output (i.e. rotate to). Real talk: these options were invented primarily for the use of the git difftool command, and may not be very useful otherwise. ๐Ÿ™ˆ
  • -R โ€” swaps the two inputs; that is, shows differences from index or on-disk file to tree contents. Flip it and reverse it. ๐Ÿ”„
  • --relative[=<path>], --no-relative โ€” okay so if you're chillin' in a subdirectory of the project, this tells git to keep it local: it excludes changes outside that directory and shows pathnames relative to it. โœจ And if you're not in a subdirectory (bare repository girlies, this means you), you can straight-up name which subdirectory you want the output relative to by passing a <path> argument. --no-relative is the uno-reverse card โ€” it countermands both the diff.relative config option and any previous --relative. ๐Ÿ’…
  • -a, --text โ€” treat all files as text. every single one. no cap. ๐Ÿซถ
  • --ignore-cr-at-eol โ€” ignore carriage-return at the end of line when it's doing a comparison. lowkey obsessed with this one.
  • --ignore-space-at-eol โ€” ignore changes in whitespace at EOL (end of line, bestie). ๐ŸŒธ
  • -b, --ignore-space-change โ€” ignore changes in the amount of whitespace. this one ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent. so a b and a b are the same vibe. โœจ
  • -w, --ignore-all-space โ€” ignore whitespace when comparing lines. and like, fully ignore โ€” it ignores differences even if one line has whitespace where the other line has none. ๐Ÿ’€
  • --ignore-blank-lines โ€” ignore changes whose lines are all blank. bye empty lines, nobody asked.
  • -I<regex>, --ignore-matching-lines=<regex> โ€” ignore changes whose all lines match <regex>. this option may be specified more than once, so stack 'em if you need to. ๐ŸŽ€
  • --inter-hunk-context=<number> โ€” show the context between diff hunks, up to the specified <number> of lines, thereby fusing hunks that are close to each other (they were meant to be together, fr). defaults to diff.interHunkContext, or 0 if that config option is unset.
  • -W, --function-context โ€” show the whole function as context lines for each change. main character function energy ๐Ÿ‘‘. the function names are determined in the same way as git diff works out patch hunk headers โ€” see "Defining a custom hunk-header" in gitattributes(5).
  • --ext-diff โ€” allow an external diff helper to be executed. so like, if you set an external diff driver with gitattributes(5), you need to use this option with git-log(1) and friends. don't forget it, bestie. ๐Ÿ”ฅ
  • --no-ext-diff โ€” disallow external diff drivers. the opposite. periodt.
  • --textconv, --no-textconv โ€” allow (or disallow) external text conversion filters to be run when comparing binary files. see gitattributes(5) for the details. and here's the important bit: because textconv filters are typically a one-way conversion, the resulting diff is suitable for human consumption but cannot be applied. ๐Ÿ˜ญ for this reason, textconv filters are enabled by default only for git-diff(1) and git-log(1) โ€” but not for git-format-patch(1) or diff plumbing commands.
  • --ignore-submodules[=(none|untracked|dirty|all)] โ€” ignore changes to submodules in the diff generation. all is the default. here's the breakdown, iykyk:
    • none โ€” considers the submodule modified when it either contains untracked or modified files, or its HEAD differs from the commit recorded in the superproject. can be used to override any settings of the ignore option in git-config(1) or gitmodules(5).
    • untracked โ€” submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content).
    • dirty โ€” ignores all changes to the work tree of submodules; only changes to the commits stored in the superproject are shown (this was the behavior until 1.7.0, vintage ๐Ÿ’…).
    • all โ€” hides all changes to submodules.
  • --src-prefix=<prefix> โ€” show the given source <prefix> instead of "a/". ๐Ÿฆ‹
  • --dst-prefix=<prefix> โ€” show the given destination <prefix> instead of "b/". matching set, adorable.
  • --no-prefix โ€” do not show any source or destination prefix. clean, minimal, no clutter.
  • --default-prefix โ€” use the default source and destination prefixes ("a/" and "b/"). this overrides configuration variables such as diff.noprefix, diff.srcPrefix, diff.dstPrefix, and diff.mnemonicPrefix (see git-config(1)). so it just snaps everything back to factory settings. โœจ
  • --line-prefix=<prefix> โ€” prepend an additional <prefix> to every line of output. every. single. line. ๐ŸŒˆ
  • --ita-invisible-in-index โ€” okay so by default, entries added by git add -N appear as an existing empty file in git diff and a new file in git diff --cached. this option makes the entry appear as a new file in git diff and non-existent in git diff --cached. it can be reverted with --ita-visible-in-index. both options are experimental and could be removed in future โ€” so like, don't build your whole personality on them. ๐Ÿ™ˆ
  • --max-depth=<depth> โ€” for each pathspec given on the command line, descend at most <depth> levels of directories. a value of -1 means no limit. cannot be combined with wildcards in the pathspec. given a tree containing foo/bar/baz, the following list shows the matches generated by each set of options:
    • --max-depth=0 -- foo: foo
    • --max-depth=1 -- foo: foo/bar
    • --max-depth=1 -- foo/bar: foo/bar/baz
    • --max-depth=1 -- foo foo/bar: foo/bar/baz
    • --max-depth=2 -- foo: foo/bar/baz

if no pathspec is given, the depth is measured as if all top-level entries were specified. note that this is different than measuring from the root, in that --max-depth=0 would still return foo. this allows you to still limit depth while asking for a subset of the top-level entries. ๐Ÿงš

โš ๏ธ note that this option is only supported for diffs between tree objects โ€” not against the index or working tree. don't try it, it's giving heartbreak.

for more detailed explanation on these common options, see also gitdiffcore(7). ๐Ÿ’–


๐ŸŽ€ GENERATING PATCH TEXT WITH -P ๐ŸŽ€

okay so running git-diff(1), git-log(1), git-show(1), git-diff-index(1), git-diff-tree(1), or git-diff-files(1) with the -p option produces patch text. and you can customize the creation of that patch text via the GIT_EXTERNAL_DIFF and the GIT_DIFF_OPTS environment variables (see git(1)), plus the diff attribute (see gitattributes(5)). ๐Ÿซถ

and here's the tea: what the -p option produces is slightly different from the traditional diff format. let's go through it:

  1. It is preceded by a "git diff" header that looks like this:
diff --git a/file1 b/file2

the a/ and b/ filenames are the same unless rename/copy is involved. especially, even for a creation or a deletion, /dev/null is not used in place of the a/ or b/ filenames. so like, don't expect it. ๐Ÿ™ˆ

when a rename/copy is involved, file1 and file2 show the name of the source file of the rename/copy and the name of the file that the rename/copy produces, respectively. โœจ

  1. It is followed by one or more extended header lines:
old mode <mode>
new mode <mode>
deleted file mode <mode>
new file mode <mode>
copy from <path>
copy to <path>
rename from <path>
rename to <path>
similarity index <number>
dissimilarity index <number>
index <hash>..<hash> <mode>

file modes <mode> are printed as 6-digit octal numbers including the file type and file permission bits. ๐Ÿ”ข

path names in extended headers do not include the a/ and b/ prefixes.

the similarity index is the percentage of unchanged lines, and the dissimilarity index is the percentage of changed lines. it's a rounded down integer, followed by a percent sign. so the similarity index value of 100% is thus reserved for two equal files, while 100% dissimilarity means that no line from the old file made it into the new one. ๐Ÿ’€ iconic, honestly.

the index line includes the blob object names before and after the change. the <mode> is included if the file mode does not change; otherwise, separate lines indicate the old and the new mode.

  1. Pathnames with "unusual" characters are quoted as explained for the configuration variable core.quotePath (see git-config(1)). ๐Ÿฆ‹
  2. All the file1 files in the output refer to files before the commit, and all the file2 files refer to files after the commit. it is incorrect to apply each change to each file sequentially. for example, this patch will swap a and b:
diff --git a/a b/b
rename from a
rename to b
diff --git a/b b/a
rename from b
rename to a

yeah. it's a whole thing. don't do the sequential apply thing, it's a trap. ๐Ÿ˜ญ

  1. Hunk headers mention the name of the function to which the hunk applies. see "Defining a custom hunk-header" in gitattributes(5) for details of how to tailor this to specific languages. ๐ŸŒธ

๐Ÿ”€ COMBINED DIFF FORMAT ๐Ÿ”€

Okay so any diff-generating command can take the -c or --cc option and it'll spit out a combined diff when it's showing you a merge. This is literally the default format when showing merges with git-diff(1) or git-show(1). Also note โ€” you can hand a suitable --diff-merges option to any of these commands to force diffs to be generated in a specific format. Flex option, honestly. ๐Ÿ’…

A "combined diff" format looks like this:

diff --combined describe.c
index fabadb8,cc95eb0..4866510
--- a/describe.c
+++ b/describe.c
@@@ -98,20 -98,12 +98,20 @@@
        return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
  }

- static void describe(char *arg)
 -static void describe(struct commit *cmit, int last_one)
++static void describe(char *arg, int last_one)
  {
 +      unsigned char sha1[20];
 +      struct commit *cmit;
        struct commit_list *list;
        static int initialized = 0;
        struct commit_name *n;

 +      if (get_sha1(arg, sha1) < 0)
 +              usage(describe_usage);
 +      cmit = lookup_commit_reference(sha1);
 +      if (!cmit)
 +              usage(describe_usage);
 +
        if (!initialized) {
                initialized = 1;
                for_each_ref(get_name);

So here's the breakdown, bestie, step by step:

  1. It's preceded by a "git diff" header that looks like this (when the -c option is used):
diff --combined file

or like this (when the --cc option is used):

diff --cc file
  1. It's followed by one or more extended header lines (this example shows a merge with two parents):
index <hash>,<hash>..<hash>
mode <mode>,<mode>..<mode>
new file mode <mode>
deleted file mode <mode>,<mode>

The mode <mode>,<mode>..<mode> line appears only if at least one of the <mode> is different from the rest. Extended headers with info about detected content movement (renames and copying detection) are designed to work with the diff of two <tree-ish> and are not used by combined diff format. Periodt.

  1. It's followed by a two-line from-file/to-file header:
--- a/file
+++ b/file

Similar to the two-line header for the traditional unified diff format, /dev/null is used to signal created or deleted files. โœจ

However, if the --combined-all-paths option is provided, instead of a two-line from-file/to-file you get an N+1 line from-file/to-file header, where N is the number of parents in the merge commit:

--- a/file
--- a/file
--- a/file
+++ b/file

This extended format can be useful if rename or copy detection is active, to allow you to see the original name of the file in different parents. Kind of iconic of it tbh ๐Ÿฆ‹

  1. Chunk header format is modified to prevent people from accidentally feeding it to patch -p1. Combined diff format was created for review of merge commit changes, and was not meant to be applied. The change is similar to the change in the extended index header:
@@@ <from-file-range> <from-file-range> <to-file-range> @@@

There are (number of parents + 1) @ characters in the chunk header for combined diff format. Math! ๐Ÿงฎ

Unlike the traditional unified diff format, which shows two files A and B with a single column that has - (minus โ€” appears in A but removed in B), + (plus โ€” missing in A but added to B), or " " (space โ€” unchanged) prefix, this format compares two or more files file1, file2,... with one file X, and shows how X differs from each of fileN. One column for each of fileN is prepended to the output line to note how X's line is different from it. Slay, more columns. ๐Ÿ’…

A - character in the column N means that the line appears in fileN but it does not appear in the result. A + character in the column N means that the line appears in the result, and fileN does not have that line (in other words, the line was added, from the point of view of that parent).

In the above example output, the function signature was changed from both files (hence two - removals from both file1 and file2, plus ++ to mean one line that was added does not appear in either file1 or file2). Also, eight other lines are the same from file1 but do not appear in file2 (hence prefixed with +). See, it all makes sense ๐ŸŒˆ

When shown by git diff-tree -c, it compares the parents of a merge commit with the merge result (i.e. file1..fileN are the parents). When shown by git diff-files -c, it compares the two unresolved merge parents with the working tree file (i.e. file1 is stage 2 aka "our version", file2 is stage 3 aka "their version"). iykyk ๐Ÿซถ


๐ŸŒธ EXAMPLES ๐ŸŒธ

git log --no-merges

Show the whole commit history, but skip any merges. No merge drama in this group chat ๐Ÿ’€

git log v2.6.12.. include/scsi drivers/scsi

Show all commits since version v2.6.12 that changed any file in the include/scsi or drivers/scsi subdirectories. Very targeted, we love a specific queen ๐Ÿ‘‘

git log --since="2 weeks ago" -- gitk

Show the changes during the last two weeks to the file gitk. The -- is necessary to avoid confusion with the branch named gitk. Don't skip it, seriously ๐Ÿ™ˆ

git log --name-status release..test

Show the commits that are in the "test" branch but not yet in the "release" branch, along with the list of paths each commit modifies. Receipts, basically ๐Ÿงพ

git log --follow builtin/rev-list.c

Shows the commits that changed builtin/rev-list.c, including those commits that occurred before the file was given its present name. It remembers the before-times โœจ

git log --branches --not --remotes=origin

Shows all commits that are in any of local branches but not in any of remote-tracking branches for origin (what you have that origin doesn't). Main character energy vs. the remote ๐Ÿ˜Œ

git log master --not --remotes=*/master

Shows all commits that are in local master but not in any remote repository master branches. Same vibe, wildcard edition ๐ŸŒ

git log -p -m --first-parent

Shows the history including change diffs, but only from the "main branch" perspective, skipping commits that come from merged branches, and showing full diffs of changes introduced by the merges. This makes sense only when following a strict policy of merging all topic branches when staying on a single integration branch. Very specific setup, respect it ๐ŸŽ€

git log -L '/int main/',/^}/:main.c

Shows how the function main() in the file main.c evolved over time. Character development arc, honestly ๐Ÿฆ‹

git log -3

Limits the number of commits to show to 3. Sometimes you just want a little snack, not the whole buffet ๐Ÿ“


๐Ÿ’œ DISCUSSION ๐Ÿ’œ

Git is to some extent character encoding agnostic. Wild, I know.

  • The contents of the blob objects are uninterpreted sequences of bytes. There is no encoding translation at the core level. None. Zero. Zip. ๐Ÿ™…โ€โ™€๏ธ
  • Path names are encoded in UTF-8 normalization form C. This applies to tree objects, the index file, ref names, as well as path names in command line arguments, environment variables and config files (.git/config (see git-config(1)), gitignore(5), gitattributes(5) and gitmodules(5)).

Note that Git at the core level treats path names simply as sequences of non-NUL bytes, there are no path name encoding conversions (except on Mac and Windows). Therefore, using non-ASCII path names will mostly work even on platforms and file systems that use legacy extended ASCII encodings. However, repositories created on such systems will not work properly on UTF-8-based systems (e.g. Linux, Mac, Windows) and vice versa. Additionally, many Git-based tools simply assume path names to be UTF-8 and will fail to display other encodings correctly. So like... proceed with caution bestie ๐Ÿ’€

  • Commit log messages are typically encoded in UTF-8, but other extended ASCII encodings are also supported. This includes ISO-8859-x, CP125x and many others, but not UTF-16/32, EBCDIC and CJK multi-byte encodings (GBK, Shift-JIS, Big5, EUC-x, CP9xx etc.). Not those, okay? ๐ŸŒธ

Although we encourage that the commit log messages are encoded in UTF-8, both the core and Git Porcelain are designed not to force UTF-8 on projects. If all participants of a particular project find it more convenient to use legacy encodings, Git does not forbid it. It's giving "you do you" ๐Ÿ’… However, there are a few things to keep in mind:

  1. git commit and git commit-tree issue a warning if the commit log message given to it does not look like a valid UTF-8 string, unless you explicitly say your project uses a legacy encoding. The way to say this is to have i18n.commitEncoding in .git/config file, like this:
[i18n]
        commitEncoding = ISO-8859-1

Commit objects created with the above setting record the value of i18n.commitEncoding in their encoding header. This is to help other people who look at them later. Lack of this header implies that the commit log message is encoded in UTF-8. Considerate icon behavior ๐ŸŽ€

  1. git log, git show, git blame and friends look at the encoding header of a commit object, and try to re-code the log message into UTF-8 unless otherwise specified. You can specify the desired output encoding with i18n.logOutputEncoding in .git/config file, like this:
[i18n]
        logOutputEncoding = ISO-8859-1

If you do not have this configuration variable, the value of i18n.commitEncoding is used instead. Fallback queen ๐Ÿ‘‘

Note that we deliberately chose not to re-code the commit log message when a commit is made to force UTF-8 at the commit object level, because re-coding to UTF-8 is not necessarily a reversible operation. So don't come for that design choice, it's load-bearing ๐Ÿ˜ญ

๐ŸŒธ CONFIGURATION ๐ŸŒธ

okay bestie, this is the config era of the page ๐Ÿ’… head over to git-config(1) for the core variables, and git-diff(1) for anything to do with generating diffs. those are your girls.

โœจ format.pretty

the default for the --format option. (peep Pretty Formats above, it's literally right there โฌ†๏ธ) defaults to medium.

โœจ i18n.logOutputEncoding

the encoding used when displaying logs. (see Discussion above, no cap.) defaults to the value of i18n.commitEncoding if that's set, and UTF-8 otherwise. cute and simple ๐ŸŽ€

โœจ log.abbrevCommit

if true, it makes git-log(1), git-show(1), and git-whatchanged(1) assume --abbrev-commit. you can override it with --no-abbrev-commit whenever you feel like it, queen ๐Ÿ‘‘

โœจ log.date

sets the default date-time mode for the log command. setting a value for log.date is basically the same as using git log's --date option โ€” see git-log(1) for the deets.

if the format is set to "auto:foo" and the pager is in use, format "foo" will be used for the date format. otherwise, "default" gets used. it's giving adaptive โœจ

โœจ log.decorate

prints out the ref names of any commits that the log command shows. possible values are:

short

the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ are not printed.

full

the full ref name (including prefix) are printed.

auto

if the output is going to a terminal, the ref names are shown as if short were given, otherwise no ref names are shown at all.

this is the same as the --decorate option of the git log. iykyk ๐Ÿฆ‹

โœจ log.initialDecorationSet

by default, git log only shows decorations for certain known ref namespaces. if all is specified, then it shows all refs as decorations. main character energy for every ref, honestly ๐Ÿ‘‘

โœจ log.excludeDecoration

excludes the specified patterns from the log decorations. this is similar to the --decorate-refs-exclude command-line option, but heads up: the config option can be overridden by the --decorate-refs option. so the command line wins, as always ๐Ÿ’…

โœจ log.diffMerges

sets the diff format to be used when --diff-merges=on is specified โ€” see --diff-merges in git-log(1) for details. defaults to separate.

โœจ log.follow

if true, git log will act as if the --follow option was used when a single <path> is given. it has the same limitations as --follow, i.e. it cannot be used to follow multiple files. one path only, bestie, that's the rule ๐Ÿซถ

โœจ log.graphColors

a list of colors, separated by commas, that can be used to draw history lines in git log --graph. aesthetic history lines, we love to see it ๐ŸŒˆ

โœจ log.graphIndent

if true, indent visual roots when rendering the graphs with --graph. set to true by default. it can be overriden with --[no-]graph-indent.

โœจ log.showRoot

if true, the initial commit will be shown as a big creation event. it's equivalent to a diff against an empty tree. tools like git-log(1) or git-whatchanged(1), which normally hide the root commit, will now show it. true by default. the origin story deserves screen time honestly ๐ŸŒฑ

โœจ log.showSignature

if true, it makes git-log(1), git-show(1), and git-whatchanged(1) assume --show-signature. signatures on, periodt โœ๏ธ

โœจ log.mailmap

if true, it makes git-log(1), git-show(1), and git-whatchanged(1) assume --use-mailmap, otherwise they assume --no-use-mailmap. true by default.

โœจ notes.mergeStrategy

which merge strategy to choose by default when resolving notes conflicts. must be one of manual, ours, theirs, union, or cat_sort_uniq. defaults to manual. see the "NOTES MERGE STRATEGIES" section of git-notes(1) for more info on each strategy โ€” she did her homework ๐Ÿ“š

this setting can be overridden by passing the --strategy option to git-notes(1).

โœจ notes.<name>.mergeStrategy

which merge strategy to choose when doing a notes merge into refs/notes/<name>. this overrides the more general notes.mergeStrategy. see the "NOTES MERGE STRATEGIES" section in git-notes(1) for more on the available strategies.

โœจ notes.displayRef

which ref (or refs, if a glob or specified more than once), in addition to the default set by core.notesRef or GIT_NOTES_REF, to read notes from when showing commit messages with the git log family of commands.

this setting can be overridden with the GIT_NOTES_DISPLAY_REF environment variable, which must be a colon separated list of refs or globs.

a warning will be issued for refs that do not exist, but a glob that does not match any refs is silently ignored. rude but valid ๐Ÿ’€

this setting can be disabled by the --no-notes option to the git-log(1) family of commands, or by the --notes=<ref> option accepted by those commands.

the effective value of core.notesRef (possibly overridden by GIT_NOTES_REF) is also implicitly added to the list of refs to be displayed. sneaky little bonus ref ๐Ÿ‘€

โœจ notes.rewrite.<command>

when rewriting commits with <command> (currently amend or rebase), if this variable is false, git will not copy notes from the original to the rewritten commit. defaults to true. see also notes.rewriteRef below.

this setting can be overridden with the GIT_NOTES_REWRITE_REF environment variable, which must be a colon separated list of refs or globs.

โœจ notes.rewriteMode

when copying notes during a rewrite (see the notes.rewrite.<command> option), determines what to do if the target commit already has a note. must be one of overwrite, concatenate, cat_sort_uniq, or ignore. defaults to concatenate.

this setting can be overridden with the GIT_NOTES_REWRITE_MODE environment variable.

โœจ notes.rewriteRef

when copying notes during a rewrite, specifies the (fully qualified) ref whose notes should be copied. may be a glob, in which case notes in all matching refs will be copied. you may also specify this configuration several times.

no default value bestie โ€” you must configure this variable to enable note rewriting. set it to refs/notes/commits to enable rewriting for the default commit notes. it will not do it for you, it's not a mind reader ๐Ÿ˜ญ

can be overridden with the GIT_NOTES_REWRITE_REF environment variable. see notes.rewrite.<command> above for a further description of its format.


๐Ÿงš GIT ๐Ÿงš

part of the git(1) suite. one of us, one of us ๐Ÿซถ


and that's a wrap on the whole page, bestie!! ๐ŸŽ€โœจ you made it to the end, iconic behavior honestly ๐Ÿ’– this was written for Git 2.56.0, dated 2026-09-27. go forth and git log responsibly, mwah ๐Ÿ’…๐ŸŒธ

๐Ÿ“ฆ where this page comes from