brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: a second -m starts a new paragraph in your commit message

Commit
~/tips/tip-commit-two-m-paragraphs

git commit -m "Fix login redirect" -m "The old code sent signed-out users to a 404."

Write a subject and a body from the command line without opening an editor.

A one line message is often too little, and I don’t always want an editor to open for two extra sentences. Give -m more than once.

Each one becomes its own paragraph:

git commit -m "Fix login redirect" -m "The old code sent signed-out users to a 404."

The first -m is the subject line and the second is the body, with a blank line between them. Check the result with:

git log -1 --format=%B

which prints:

Fix login redirect

The old code sent signed-out users to a 404.

That blank line matters. Tools that show only the subject, such as git log --oneline, stay readable, and the explanation is there for anyone who opens the full commit. I use the body to say why the change was needed, since the diff already shows what changed.

A word on quoting. Inside double quotes the shell still expands $ and backticks, so a message that mentions a variable name can come out wrong. Use single quotes around such text. And if you find yourself adding a fourth -m, drop them all and run git commit with no message so you can write in your editor.

Further reading: git-commit documentation

More Commit tips if ! head -n1 "$1" | grep -qE '^[A-Z]'; then git commit -C ORIG_HEAD git commit --fixup=reword:HEAD~1 git config --global commit.cleanup scissors Commit.template pre-fills your commit message All Commit tips (7) All topics

Link