git show --format="YOUR_FORMAT" -s

-s suppresses the diffs from showing.

YOUR_FORMAT is documented at:

man git-log

section PRETTY FORMATS

For example, to get just commit SHAs and author email for a few SHAs:

git show --format="%H %ae" -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f

gives output for format:

62f6870e4e0b384c4bd2d514116247e81b241251 [email protected]
96ee0246ce52012644dd18cf360e64c49016fb7f [email protected]

To add newlines and more fields to the format, you could do:

git show --format=$'%H\n%ae\n%an\n' -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f

Which gives output for form:

62f6870e4e0b384c4bd2d514116247e81b241251
[email protected]
Ciro Santilli

96ee0246ce52012644dd18cf360e64c49016fb7f
[email protected]
Ciro Santilli
Answer from Ciro Santilli OurBigBook.com on Stack Overflow
🌐
Git
git-scm.com › docs › pretty-formats
Git - pretty-formats Documentation
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
🌐
Devhints
devhints.io › git › git log format string cheatsheet
Git log format string cheatsheet
git log --pretty=format:%H · %H - Commit hash · %an - Author · � - Author date · One-page guide to Git log format string
Discussions

shell - How to use git show with pretty or format that come up with just commit message brief? - Stack Overflow
The output should look like git log, no any file and code changes just commit message brief, as below: commit Author: Commit: More on stackoverflow.com
🌐 stackoverflow.com
command line - How to change Git log date formats - Stack Overflow
I pasted your command as-is and ... format format:%Y-%m-%d %H:%M:%S. I am running git on windows. Here's my git version. git version 1.9.5.msysgit.1. So do I have to upgrade to the newer version? 2016-03-06T21:24:07.49Z+00:00 ... Offering this complete example (so I can find ... More on stackoverflow.com
🌐 stackoverflow.com
Is there a way to format commit messages in Git Bash?
Git commit messages are plain text. Some tools (eg: GitHub and GitLab) will render commit messages as markdown . This is mostly okay, but I would strongly advise against using any markdown that isn't lowest common denominator (that is, don't use any syntax specific to GitHub flavored markdown). Also, I'd avoid using any markdown that isn't easily readable as plain text. For the most part, that means I'm ok with using backticks, asterisks for emphasis, bulleted lists, and indented code blocks. (I normally prefer triple back ticks for code blocks in markdown, but in git commits I prefer to use 4-space indents as I feel they are easier to read in a plain text environment). I also avoid using anything fancy like tables, embedded HTML (which markdown allows), or even links as they are not very legible in a plain text environment. Also, commit messages should use hard line wrapping. Edit: some typo corrections More on reddit.com
🌐 r/git
11
7
August 23, 2023
Git log source in pretty format - Stack Overflow
Is there any way to show source while using pretty=format? Im getting information on which track specific commit was pushed by command git log --source --oneline But I also need a date=short whic... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › hallettj › git-format-staged
GitHub - hallettj/git-format-staged: Git command to transform staged files using a formatting command · GitHub
The result is more manual effort compared to git-format-staged. the one-liner git diff --diff-filter=d --cached | grep '^[+-]' | grep -Ev '^(--- a/|\+\+\+ b/)' | LINT_COMMAND (described here) extracts changed hunks and feeds them to a linter. But linting will fail if the linter requires the entire file for context. For example a linter might report errors if it cannot see import lines.
Starred by 240 users
Forked by 23 users
Languages   TypeScript 49.6% | Python 36.1% | Nix 12.6%
🌐
Git
git-scm.com › docs › git-format-patch
Git - git-format-patch Documentation
As a reviewer aid, insert a range-diff ... series if it shares a common base with the series being formatted (for example git format-patch --cover-letter --range-diff=feature/v1 -3 feature/v2), or a revision range if the two versions of the series are disjoint (for example git ...
Top answer
1 of 4
12

git show --format="YOUR_FORMAT" -s

-s suppresses the diffs from showing.

YOUR_FORMAT is documented at:

man git-log

section PRETTY FORMATS

For example, to get just commit SHAs and author email for a few SHAs:

git show --format="%H %ae" -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f

gives output for format:

62f6870e4e0b384c4bd2d514116247e81b241251 [email protected]
96ee0246ce52012644dd18cf360e64c49016fb7f [email protected]

To add newlines and more fields to the format, you could do:

git show --format=$'%H\n%ae\n%an\n' -s 62f6870e4e0b384c4bd2d514116247e81b241251 96ee0246ce52012644dd18cf360e64c49016fb7f

Which gives output for form:

62f6870e4e0b384c4bd2d514116247e81b241251
[email protected]
Ciro Santilli

96ee0246ce52012644dd18cf360e64c49016fb7f
[email protected]
Ciro Santilli
2 of 4
5

Im using this script (as alias):

https://github.com/vheon/home/blob/master/.githelpers

git alias:

l = "!bash -c 'source ~/.githelpers && pretty_git_log'"

the output is this:


You will have to use your own git log --pretty=format options.

In the --pretty you can set colors and choose any content you would like to display


format:<string>

The format: 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.

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:

%C(…): color specification, as described in color.branch.* config option; adding auto, at the beginning will emit color only when colors are 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). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.

%C(…): color specification, as described in color.branch.* config option; adding auto, at the beginning will emit color only when colors are 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). auto alone (i.e. %C(auto)) will turn on auto coloring on the next placeholders until the color is switched again.

%Cblue: switch color to blue
%Cgreen: switch color to green
%Cred: switch color to red
%Creset: reset color
%D: ref names without the " (", ")" wrapping.
%G?: show "G" for a Good signature, "B" for a Bad signature, "U" for a good, untrusted signature and "N" for no signature
%GG: raw verification message from GPG for a signed commit
%GK: show the key used to sign a signed commit
%GS: show the name of the signer for a signed commit
%H: commit hash
%N: commit notes
%P: parent hashes
%T: tree hash
%aD: author date, RFC2822 style
%aE: author email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%aI: author date, strict ISO 8601 format
%aN: author name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%ad: author date (format respects --date= option)
%ae: author email
%ai: author date, ISO 8601-like format
%an: author name
%ar: author date, relative
%at: author date, UNIX timestamp
%b: body
%cD: committer date, RFC2822 style
%cE: committer email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cI: committer date, strict ISO 8601 format
%cN: committer name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%cd: committer date (format respects --date= option)
%ce: committer email
%ci: committer date, ISO 8601-like format
%cn: committer name
%cr: committer date, relative
%ct: committer date, UNIX timestamp
%d: ref names, like the --decorate option of git-log(1)
%e: encoding
%f: sanitized subject line, suitable for a filename
%gD: reflog selector, e.g., refs/stash@{1}
%gE: reflog identity email (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gN: reflog identity name (respecting .mailmap, see git-shortlog(1) or git-blame(1))
%gd: shortened reflog selector, e.g., stash@{1}
%ge: reflog identity email
%gn: reflog identity name
%gs: reflog subject
%h: abbreviated commit hash
%m: left, right or boundary mark
%n: newline
%p: abbreviated parent hashes
%s: subject
%t: abbreviated tree hash
%w([<w>[,<i1>[,<i2>]]]): switch line wrapping, like the -w option of git-shortlog(1).
%x00: print a byte from a hex code

🌐
Jeff Kreeftmeijer
jeffkreeftmeijer.com › git-log-formats
Git log formats
July 17, 2021 - commit a0806341633cc7f3b4a93c4cd6ff395ba904f873 Author: Alice <alice@example.com> AuthorDate: Sat Jul 17 12:32:11 2021 +0200 Commit: Bob <bob@example.com> CommitDate: Sat Jul 17 13:12:37 2021 +0200 Subject First paragraph Second paragraph
🌐
Edureka
edureka.co › blog › git-format-commit-history
Git log format history | Use Git log to format the commit history | Edureka
September 14, 2024 - The format allows you to specify ... printf’ function with the help of code snippets: Command: git log --pretty=format:"%h � | %s %d [%an]" --date=short Output format: <sha-1> <author date> | <commit title> <refname> [author ...
🌐
Rene Nyffenegger
renenyffenegger.ch › notes › development › version-control-systems › git › commands › _options › format-pretty
Git: --format | --pretty
$ ~/linux git log -1 --format=%s ; git log -1 --format=%f Merge tag 'gpio-fixes-for-v6.7-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux Merge-tag-gpio-fixes-for-v6.7-rc8-of-git-git.kernel.org-pub-scm-linux-kernel-git-brgl-linux
Find elsewhere
🌐
Git
git-scm.com › docs › git-log
Git - git-log Documentation
For example, these two are equivalent: $ git log -2 --pretty=tformat:%h 4da45bef $ git log -2 --pretty=%h 4da45bef · By default, git log does not generate any diff output. The options below can be used to show the changes made by each commit. Note that unless one of --diff-merges variants ...
🌐
Git
git-scm.com › docs › diff-format
Git - diff-format Documentation
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 +). When shown by git diff-tree -c, it compares the parents of a merge commit with the merge result (i.e.
🌐
Git
git-scm.com › docs › pretty-options
Git - pretty-options Documentation
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> ...
Top answer
1 of 12
318

In addition to --date=(relative|local|default|iso|iso-strict|rfc|short|raw), as others have mentioned, you can also use a custom log date format with

--date=format:'%Y-%m-%d %H:%M:%S'       # committer's timezone
--date=format-local:'%Y-%m-%d %H:%M:%S' # current user's timezone

This outputs something like 2016-01-13 11:32:13.

NOTE: If you take a look at the commit linked to below, I believe you'll need at least Git v2.6.0-rc0 for this to work.

In a full command it would be something like:

git config --global alias.lg "log --graph --decorate -30 --all --topo-order --date=format-local:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'"

I haven't been able to find this in documentation anywhere (if someone knows where to find it, please comment) so I originally found the placeholders by trial and error.

In my search for documentation on this I found a commit to Git itself that indicates the format is fed directly to strftime. Looking up strftime (here or here) the placeholders I found match the placeholders listed.

The placeholders include:

%a      Abbreviated weekday name
%A      Full weekday name
%b      Abbreviated month name
%B      Full month name
%c      Date and time representation appropriate for locale
%d      Day of month as decimal number (01 – 31)
%H      Hour in 24-hour format (00 – 23)
%I      Hour in 12-hour format (01 – 12)
%j      Day of year as decimal number (001 – 366)
%m      Month as decimal number (01 – 12)
%M      Minute as decimal number (00 – 59)
%p      Current locale's A.M./P.M. indicator for 12-hour clock
%S      Second as decimal number (00 – 59)
%U      Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w      Weekday as decimal number (0 – 6; Sunday is 0)
%W      Week of year as decimal number, with Monday as first day of week (00 – 53)
%x      Date representation for current locale
%X      Time representation for current locale
%y      Year without century, as decimal number (00 – 99)
%Y      Year with century, as decimal number
%z, %Z  Either the time-zone name or time zone abbreviation, depending on registry settings
%%      Percent sign
2 of 12
220

The others are (from git help log):

--date=(relative|local|default|iso|rfc|short|raw)
  Only takes effect for dates shown in human-readable format,
  such as when using "--pretty".  log.date config variable
  sets a default value for log command’s --date option.

--date=relative shows dates relative to the current time, e.g. "2 hours ago".

--date=local shows timestamps in user’s local timezone.

--date=iso (or --date=iso8601) shows timestamps in ISO 8601 format.

--date=rfc (or --date=rfc2822) shows timestamps in RFC 2822 format,
  often found in E-mail messages.

--date=short shows only date but not time, in YYYY-MM-DD format.

--date=raw shows the date in the internal raw git format %s %z format.

--date=default shows timestamps in the original timezone
  (either committer’s or author’s).

There is no built-in way that I know of to create a custom format, but you can do some shell magic.

timestamp=`git log -n1 --format="%at"`
my_date=`perl -e "print scalar localtime ($timestamp)"`
git log -n1 --pretty=format:"Blah-blah $my_date"

The first step here gets you a millisecond timestamp. You can change the second line to format that timestamp however you want. This example gives you something similar to --date=local, with a padded day.


And if you want permanent effect without typing this every time, try

git config log.date iso 

Or, for effect on all your git usage with this account

git config --global log.date iso
🌐
Coderwall
coderwall.com › p › euwpig › a-better-git-log
A better git log (Example)
December 10, 2025 - git log --format='%Cred%h%Creset %s %Cgreen(%cr) %C(blue)<%an>%Creset%C(yellow)%d%Creset' --no-merges
🌐
GitHub
docs.github.com › en › get-started › writing-on-github › getting-started-with-writing-and-formatting-on-github › basic-writing-and-formatting-syntax
Basic writing and formatting syntax - GitHub Docs
This example Will have a blank line separating both lines · You can display an image by adding ! and wrapping the alt text in [ ]. Alt text is a short text equivalent of the information in the image. Then, wrap the link for the image in parentheses (). ![Screenshot of a comment on a GitHub issue showing an image, added in the Markdown, of an Octocat smiling and raising a tentacle.](https://myoctocat.com/assets/images/base-octocat.svg)
🌐
Reddit
reddit.com › r/git › is there a way to format commit messages in git bash?
r/git on Reddit: Is there a way to format commit messages in Git Bash?
August 23, 2023 -

Hello. I'm new to using Git in the CLI (Windows), but I've used GitHub Desktop for a brief period before.

In GitHub Desktop, you can format text with backticks (`file_name.txt`) to make it appear as inline code. Is there a way to do something similar in Git Bash? Also, is there some cheat sheet with all possible formats? I've been Googling and the most I've found is "how to write good commits" type articles.

🌐
Medium
jonelle-noelani.medium.com › git-pretty-9985da1f14ea
Git Pretty. I occasionally switch back and forth… | by Jonelle Noelani Yacapin | Medium
May 18, 2021 - Instead of piecing together my own string of placeholders and commands, I’m glad I found this blog by Chris Simpkins that provided me something to work with. git log --graph --pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) ...
Top answer
1 of 4
44

Create a minimal example and reverse engineer the format

Create a simple repository, and before any packfiles are created (git gc, git config gc.auto, git-prune-packed ...), unpack a commit object with one of the methods from: How to DEFLATE with a command line tool to extract a git object?

export GIT_AUTHOR_DATE="1970-01-01T00:00:00+0000"
export GIT_AUTHOR_EMAIL="author@example.com"
export GIT_AUTHOR_NAME="Author Name" \
export GIT_COMMITTER_DATE="2000-01-01T00:00:00+0000" \
export GIT_COMMITTER_EMAIL="committer@example.com" \
export GIT_COMMITTER_NAME="Committer Name" \

git init

# First commit.
echo
touch a
git add a
git commit -m 'First message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/45/3a2378ba0eb310df8741aa26d1c861ac4c512f | hd

# Second commit.
echo
touch b
git add b
git commit -m 'Second message'
# (for python2, remove the two `.buffer`s in the next line)
python -c "import zlib,sys;sys.stdout.buffer.write(zlib.decompress(sys.stdin.buffer.read()))" \
  <.git/objects/74/8e6f7e22cac87acec8c26ee690b4ff0388cbf5 | hd

The output is:

Initialized empty Git repository in /home/ciro/test/git/.git/

[master (root-commit) 453a237] First message
 Author: Author Name <author@example.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a
00000000  63 6f 6d 6d 69 74 20 31  37 34 00 74 72 65 65 20  |commit 174.tree |
00000010  34 39 36 64 36 34 32 38  62 39 63 66 39 32 39 38  |496d6428b9cf9298|
00000020  31 64 63 39 34 39 35 32  31 31 65 36 65 31 31 32  |1dc9495211e6e112|
00000030  30 66 62 36 66 32 62 61  0a 61 75 74 68 6f 72 20  |0fb6f2ba.author |
00000040  41 75 74 68 6f 72 20 4e  61 6d 65 20 3c 61 75 74  |Author Name <aut|
00000050  68 6f 72 40 65 78 61 6d  70 6c 65 2e 63 6f 6d 3e  |hor@example.com>|
00000060  20 30 20 2b 30 30 30 30  0a 63 6f 6d 6d 69 74 74  | 0 +0000.committ|
00000070  65 72 20 43 6f 6d 6d 69  74 74 65 72 20 4e 61 6d  |er Committer Nam|
00000080  65 20 3c 63 6f 6d 6d 69  74 74 65 72 40 65 78 61  |e <committer@exa|
00000090  6d 70 6c 65 2e 63 6f 6d  3e 20 39 34 36 36 38 34  |mple.com> 946684|
000000a0  38 30 30 20 2b 30 30 30  30 0a 0a 46 69 72 73 74  |800 +0000..First|
000000b0  20 6d 65 73 73 61 67 65  0a                       | message.|
000000ba

[master 748e6f7] Second message
 Author: Author Name <author@example.com>
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 b
00000000  63 6f 6d 6d 69 74 20 32  32 33 00 74 72 65 65 20  |commit 223.tree |
00000010  32 39 36 65 35 36 30 32  33 63 64 63 30 33 34 64  |296e56023cdc034d|
00000020  32 37 33 35 66 65 65 38  63 30 64 38 35 61 36 35  |2735fee8c0d85a65|
00000030  39 64 31 62 30 37 66 34  0a 70 61 72 65 6e 74 20  |9d1b07f4.parent |
00000040  34 35 33 61 32 33 37 38  62 61 30 65 62 33 31 30  |453a2378ba0eb310|
00000050  64 66 38 37 34 31 61 61  32 36 64 31 63 38 36 31  |df8741aa26d1c861|
00000060  61 63 34 63 35 31 32 66  0a 61 75 74 68 6f 72 20  |ac4c512f.author |
00000070  41 75 74 68 6f 72 20 4e  61 6d 65 20 3c 61 75 74  |Author Name <aut|
00000080  68 6f 72 40 65 78 61 6d  70 6c 65 2e 63 6f 6d 3e  |hor@example.com>|
00000090  20 30 20 2b 30 30 30 30  0a 63 6f 6d 6d 69 74 74  | 0 +0000.committ|
000000a0  65 72 20 43 6f 6d 6d 69  74 74 65 72 20 4e 61 6d  |er Committer Nam|
000000b0  65 20 3c 63 6f 6d 6d 69  74 74 65 72 40 65 78 61  |e <committer@exa|
000000c0  6d 70 6c 65 2e 63 6f 6d  3e 20 39 34 36 36 38 34  |mple.com> 946684|
000000d0  38 30 30 20 2b 30 30 30  30 0a 0a 53 65 63 6f 6e  |800 +0000..Secon|
000000e0  64 20 6d 65 73 73 61 67  65 0a                    |d message.|
000000eb

Then we deduce that the format is as follows:

  • Top level:

    commit {size}\0{content}
    

    where {size} is the number of bytes in {content}.

    This follows the same pattern for all object types.

  • {content}:

    tree {tree_sha}
    {parents}
    author {author_name} <{author_email}> {author_date_seconds} {author_date_timezone}
    committer {committer_name} <{committer_email}> {committer_date_seconds} {committer_date_timezone}
    
    {commit message}
    

    where:

    • {tree_sha}: SHA of the tree object this commit points to.

      This represents the top-level Git repo directory.

      That SHA comes from the format of the tree object: What is the internal format of a Git tree object?

    • {parents}: optional list of parent commit objects of form:

      parent {parent1_sha}
      parent {parent2_sha}
      ...
      

      The list can be empty if there are no parents, e.g. for the first commit in a repo.

      Two parents happen in regular merge commits.

      More than two parents are possible with git merge -Xoctopus, but this is not a common workflow. Here is an example: https://github.com/cirosantilli/test-octopus-100k

    • {author_name}: e.g.: Ciro Santilli. Cannot contain <, \n

    • {author_email}: e.g.: cirosantilli@mail.com. Cannot contain >, \n

    • {author_date_seconds}: seconds since 1970, e.g. 946684800 is the first second of year 2000

    • {author_date_timezone}: e.g.: +0000 is UTC

    • committer fields: analogous to author fields

    • {commit message}: arbitrary.

I've made a minimal Python script that generates a git repo with a few commits at: https://github.com/cirosantilli/test-git-web-interface/blob/864d809c36b8f3b232d5b0668917060e8bcba3e8/other-test-repos/util.py#L83

I've used that for fun things like:

  • Who is the user with the longest streak on GitHub?
  • https://www.quora.com/Which-GitHub-repo-has-the-most-commits/answer/Ciro-Santilli
  • https://github.com/isaacs/github/issues/1344

Here is an analogous analysis of the tag object format: What is the format of a git tag object and how to calculate its SHA?

2 of 4
26

Before you head down this path much further, I might recommend that you read through the section in the Git Manual about its internals. I find that knowing the contents of this chapter is usually the difference between liking Git and hating it. Understanding why Git is doing things the way it does often makes all of the sort of weird commands it has for things make more sense.

To answer your question, the gibberish that you are seeing is the data for the object after it has been compressed using zlib. If you look under the heading "Object Storage" in the link above you can see some details about how this works. This is the short version of how files are stored in Git:

  1. Create a Git specific header for the content.
  2. Generate a hash of the concatenation of the header + content.
  3. Compress the concatenation of the header + content.
  4. Store the compressed data to disk in a folder with a name equal to the first two characters of the data's hash and a file name with the remaining 38 characters.

So that answers your second question, a folder will contain all of the compressed objects that begin with the same two characters, regardless of their contents.

If you want to see the contents of a blob, all you have to do is decompress it. If you just want to view the contents of the file, this can be done easily enough in most programming languages. I would warn you against trying to modify data, however. Modifying even a single byte in a file will change its hash. All of the metadata in Git (namely, directory structures and commits) are stored using references to hashes, so modifying a single file means that you must also update all objects downstream from that file that reference that file's hash.

Then you have to update all the objects that reference those hashes. And on, and on, and on... Trying to achieve this becomes very, very complicated very quickly. You'll save yourself a lot of time and heartache by just learning Git's built in commands.