<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">

<article lang="en" id="git-show(1)">
<articleinfo>
    <title>git-show(1)</title>
        <indexterm>
                <primary>git-show(1)</primary>
        </indexterm>
</articleinfo>
<simplesect id="_name">
<title>NAME</title>
<simpara>git-show - Show various types of objects</simpara>
</simplesect>
<simplesect id="_synopsis">
<title>SYNOPSIS</title>
<simpara><emphasis>git show</emphasis> [options] &lt;object&gt;&#8230;</simpara>
</simplesect>
<simplesect id="_description">
<title>DESCRIPTION</title>
<simpara>Shows one or more objects (blobs, trees, tags and commits).</simpara>
<simpara>For commits it shows the log message and textual diff. It also
presents the merge commit in a special format as produced by
<emphasis>git-diff-tree --cc</emphasis>.</simpara>
<simpara>For tags, it shows the tag message and the referenced objects.</simpara>
<simpara>For trees, it shows the names (equivalent to <emphasis>git-ls-tree</emphasis>
with --name-only).</simpara>
<simpara>For plain blobs, it shows the plain contents.</simpara>
<simpara>The command takes options applicable to the <emphasis>git-diff-tree</emphasis> command to
control how the changes the commit introduces are shown.</simpara>
<simpara>This manual page describes only the most frequently used options.</simpara>
</simplesect>
<simplesect id="_options">
<title>OPTIONS</title>
<variablelist>
<varlistentry>
<term>
&lt;object&gt;&#8230;
</term>
<listitem>
<simpara>
        The names of objects to show.
        For a more complete list of ways to spell object names, see
        "SPECIFYING REVISIONS" section in <xref linkend="git-rev-parse(1)"/>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--pretty[=<emphasis>&lt;format&gt;</emphasis>]
</term>
<listitem>
<simpara>
        Pretty-print the contents of the commit logs in a given format,
        where <emphasis>&lt;format&gt;</emphasis> can be one of <emphasis>oneline</emphasis>, <emphasis>short</emphasis>, <emphasis>medium</emphasis>,
        <emphasis>full</emphasis>, <emphasis>fuller</emphasis>, <emphasis>email</emphasis>, <emphasis>raw</emphasis> and <emphasis>format:&lt;string&gt;</emphasis>.
        When omitted, the format defaults to <emphasis>medium</emphasis>.
</simpara>
<simpara>Note: you can specify the default pretty format in the repository
configuration (see <xref linkend="git-config(1)"/>).</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--abbrev-commit
</term>
<listitem>
<simpara>
        Instead of showing the full 40-byte hexadecimal commit object
        name, show only a partial prefix.  Non default number of
        digits can be specified with "--abbrev=&lt;n&gt;" (which also modifies
        diff output, if it is displayed).
</simpara>
<simpara>This should make "--pretty=oneline" a whole lot more readable for
people using 80-column terminals.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
--encoding[=&lt;encoding&gt;]
</term>
<listitem>
<simpara>
        The commit objects record the 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.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_pretty_formats">
<title>PRETTY FORMATS</title>
<simpara>If the commit is a merge, and if the pretty-format
is not <emphasis>oneline</emphasis>, <emphasis>email</emphasis> or <emphasis>raw</emphasis>, an additional line is
inserted before the <emphasis>Author:</emphasis> line.  This line begins with
"Merge: " and the sha1s of ancestral commits are printed,
separated by spaces.  Note that the listed commits may not
necessarily be the list of the <emphasis role="strong">direct</emphasis> 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.</simpara>
<simpara>Here are some additional details for each format:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>oneline</emphasis>
</simpara>
<literallayout class="monospaced">&lt;sha1&gt; &lt;title line&gt;</literallayout>
<simpara>This is designed to be as compact as possible.</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>short</emphasis>
</simpara>
<literallayout class="monospaced">commit &lt;sha1&gt;
Author: &lt;author&gt;</literallayout>
<literallayout class="monospaced">&lt;title line&gt;</literallayout>
</listitem>
<listitem>
<simpara>
<emphasis>medium</emphasis>
</simpara>
<literallayout class="monospaced">commit &lt;sha1&gt;
Author: &lt;author&gt;
Date:   &lt;author date&gt;</literallayout>
<literallayout class="monospaced">&lt;title line&gt;</literallayout>
<literallayout class="monospaced">&lt;full commit message&gt;</literallayout>
</listitem>
<listitem>
<simpara>
<emphasis>full</emphasis>
</simpara>
<literallayout class="monospaced">commit &lt;sha1&gt;
Author: &lt;author&gt;
Commit: &lt;committer&gt;</literallayout>
<literallayout class="monospaced">&lt;title line&gt;</literallayout>
<literallayout class="monospaced">&lt;full commit message&gt;</literallayout>
</listitem>
<listitem>
<simpara>
<emphasis>fuller</emphasis>
</simpara>
<literallayout class="monospaced">commit &lt;sha1&gt;
Author:     &lt;author&gt;
AuthorDate: &lt;author date&gt;
Commit:     &lt;committer&gt;
CommitDate: &lt;committer date&gt;</literallayout>
<literallayout class="monospaced">&lt;title line&gt;</literallayout>
<literallayout class="monospaced">&lt;full commit message&gt;</literallayout>
</listitem>
<listitem>
<simpara>
<emphasis>email</emphasis>
</simpara>
<literallayout class="monospaced">From &lt;sha1&gt; &lt;date&gt;
From: &lt;author&gt;
Date: &lt;author date&gt;
Subject: [PATCH] &lt;title line&gt;</literallayout>
<literallayout class="monospaced">&lt;full commit message&gt;</literallayout>
</listitem>
<listitem>
<simpara>
<emphasis>raw</emphasis>
</simpara>
<simpara>The <emphasis>raw</emphasis> format shows the entire commit exactly as
stored in the commit object.  Notably, the SHA1s are
displayed in full, regardless of whether --abbrev or
--no-abbrev are used, and <emphasis>parents</emphasis> information show the
true parent commits, without taking grafts nor history
simplification into account.</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>format:</emphasis>
</simpara>
<simpara>The <emphasis>format:</emphasis> 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 <emphasis>%n</emphasis>
instead of <emphasis>\n</emphasis>.</simpara>
<simpara>E.g, <emphasis>format:"The author of %h was %an, %ar%nThe title was &gt;&gt;%s&lt;&lt;%n"</emphasis>
would show something like this:</simpara>
<literallayout>The author of fe6e0ee was Junio C Hamano, 23 hours ago
The title was &gt;&gt;t4119: test autocomputing -p&lt;n&gt; for traditional diff input.&lt;&lt;</literallayout>
<simpara>The placeholders are:</simpara>
<itemizedlist>
<listitem>
<simpara>
<emphasis>%H</emphasis>: commit hash
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%h</emphasis>: abbreviated commit hash
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%T</emphasis>: tree hash
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%t</emphasis>: abbreviated tree hash
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%P</emphasis>: parent hashes
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%p</emphasis>: abbreviated parent hashes
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%an</emphasis>: author name
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%aN</emphasis>: author name (respecting .mailmap)
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ae</emphasis>: author email
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%aE</emphasis>: author email (respecting .mailmap)
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ad</emphasis>: author date (format respects --date= option)
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%aD</emphasis>: author date, RFC2822 style
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ar</emphasis>: author date, relative
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%at</emphasis>: author date, UNIX timestamp
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ai</emphasis>: author date, ISO 8601 format
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cn</emphasis>: committer name
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cN</emphasis>: committer name (respecting .mailmap)
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ce</emphasis>: committer email
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cE</emphasis>: committer email (respecting .mailmap)
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cd</emphasis>: committer date
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cD</emphasis>: committer date, RFC2822 style
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%cr</emphasis>: committer date, relative
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ct</emphasis>: committer date, UNIX timestamp
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%ci</emphasis>: committer date, ISO 8601 format
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%d</emphasis>: ref names, like the --decorate option of <xref linkend="git-log(1)"/>
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%e</emphasis>: encoding
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%s</emphasis>: subject
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%b</emphasis>: body
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%Cred</emphasis>: switch color to red
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%Cgreen</emphasis>: switch color to green
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%Cblue</emphasis>: switch color to blue
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%Creset</emphasis>: reset color
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%C(&#8230;)</emphasis>: color specification, as described in color.branch.* config option
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%m</emphasis>: left, right or boundary mark
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%n</emphasis>: newline
</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>%x00</emphasis>: print a byte from a hex code
</simpara>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<simpara>
<emphasis>tformat:</emphasis>
</simpara>
<simpara>The <emphasis>tformat:</emphasis> format works exactly like <emphasis>format:</emphasis>, 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:</simpara>
<literallayout>$ 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</literallayout>
</listitem>
</itemizedlist>
</simplesect>
<simplesect id="_examples">
<title>EXAMPLES</title>
<variablelist>
<varlistentry>
<term>
git show v1.0.0
</term>
<listitem>
<simpara>
        Shows the tag <literal>v1.0.0</literal>, along with the object the tags
        points at.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git show v1.0.0^{tree}
</term>
<listitem>
<simpara>
        Shows the tree pointed to by the tag <literal>v1.0.0</literal>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git show next~10:Documentation/README
</term>
<listitem>
<simpara>
        Shows the contents of the file <literal>Documentation/README</literal> as
        they were current in the 10th last commit of the branch
        <literal>next</literal>.
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>
git show master:Makefile master:t/Makefile
</term>
<listitem>
<simpara>
        Concatenates the contents of said Makefiles in the head
        of the branch <literal>master</literal>.
</simpara>
</listitem>
</varlistentry>
</variablelist>
</simplesect>
<simplesect id="_discussion">
<title>Discussion</title>
<simpara>At the core level, git is character encoding agnostic.</simpara>
<itemizedlist>
<listitem>
<simpara>
The pathnames recorded in the index and in the tree objects
   are treated as uninterpreted sequences of non-NUL bytes.
   What readdir(2) returns are what are recorded and compared
   with the data git keeps track of, which in turn are expected
   to be what lstat(2) and creat(2) accepts.  There is no such
   thing as pathname encoding translation.
</simpara>
</listitem>
<listitem>
<simpara>
The contents of the blob objects are uninterpreted sequences
   of bytes.  There is no encoding translation at the core
   level.
</simpara>
</listitem>
<listitem>
<simpara>
The commit log messages are uninterpreted sequences of non-NUL
   bytes.
</simpara>
</listitem>
</itemizedlist>
<simpara>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.  However, there are a few things to keep in
mind.</simpara>
<orderedlist numeration="arabic">
<listitem>
<simpara>
<emphasis>git-commit</emphasis> and <emphasis>git-commit-tree</emphasis> issues
  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 <literal>.git/config</literal> file, like this:
</simpara>
<literallayout>[i18n]
        commitencoding = ISO-8859-1</literallayout>
<simpara>Commit objects created with the above setting record the value
of <literal>i18n.commitencoding</literal> in its <literal>encoding</literal> 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.</simpara>
</listitem>
<listitem>
<simpara>
<emphasis>git-log</emphasis>, <emphasis>git-show</emphasis>, <emphasis>git-blame</emphasis> and friends look at the
  <literal>encoding</literal> 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
  <literal>i18n.logoutputencoding</literal> in <literal>.git/config</literal> file, like this:
</simpara>
<literallayout>[i18n]
        logoutputencoding = ISO-8859-1</literallayout>
<simpara>If you do not have this configuration variable, the value of
<literal>i18n.commitencoding</literal> is used instead.</simpara>
</listitem>
</orderedlist>
<simpara>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.</simpara>
</simplesect>
<simplesect id="_author">
<title>Author</title>
<simpara>Written by Linus Torvalds &lt;<ulink url="mailto:torvalds@osdl.org">torvalds@osdl.org</ulink>&gt; and
Junio C Hamano &lt;<ulink url="mailto:gitster@pobox.com">gitster@pobox.com</ulink>&gt;.  Significantly enhanced by
Johannes Schindelin &lt;<ulink url="mailto:Johannes.Schindelin@gmx.de">Johannes.Schindelin@gmx.de</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_documentation">
<title>Documentation</title>
<simpara>Documentation by David Greaves, Petr Baudis and the git-list &lt;<ulink url="mailto:git@vger.kernel.org">git@vger.kernel.org</ulink>&gt;.</simpara>
</simplesect>
<simplesect id="_git">
<title>GIT</title>
<simpara>Part of the <xref linkend="git(1)"/> suite</simpara>
</simplesect>
</article>
