• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Solution / Show Git Commit Message without Indentation

Show Git Commit Message without Indentation

Last updated on January 27, 2026 by Sal Ferrarello

Sometimes I want a Git commit message without the leading indentation added by git show (for example, if I want to copy it and paste it somewhere else). This command gives me this output:

git show --no-patch --format='%B'

we can also optionally pass a reference to a Git commit (e.g. a branch, hash, or tag) just like we can with git show, e.g.

git show --no-patch --format='%B' HEAD~2

Alias

I have this command aliased to shnpfb (which is based on SHow No Patch Format B), though I typically type git shn<tab> so I can use tab completion and don’t have to think about all the letters.

You can add this alias to your global Git config file by running the following from the command line.

git config --global alias.shnpfb "show --no-patch --format='%B'"

Here is the commit where I added shnpfb to my Git config.

How it Works

The --no-patch flag excludes the actual code changes (a.k.a. the “patch”) from the output of git show

The --format flag for git show takes the same values as the Pretty Formats for Git Log, specifically we’re using %B which is

raw body (unwrapped subject and body)

Copying to the Clipboard on a Mac

On my Mac, I use the pbcopy command to copy the commit message to the clipboard.

e.g.

git show --no-patch --format='%B' | pbcopy

or with my alias

git shnpfb | pbcopy
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Dev Tips, Solution Tagged With: Git, git alias, gitconfig

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in