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: commit.cleanup scissors keeps # lines in your commit message

Commit
~/tips/tip-commit-cleanup-scissors

git config --global commit.cleanup scissors

Stop Git from silently dropping message lines that start with a hash.

Write a Markdown heading or start a line with an issue number like #142 in the editor, and the line vanishes from the commit. By default, much to my annoyance, Git treats every line beginning with # as a comment and strips it.

The scissors mode changes how it decides what to throw away:

git config --global commit.cleanup scissors

From then on the editor shows a marker line like this one:

# ------------------------ >8 ------------------------

Everything below the marker is removed, including the status hints and, with verbose mode, the diff. Everything above it stays, hash lines included. So this message survives as written:

Update the setup notes

#142 asked for a clearer install section.

To try it once before changing your config, pass it for a single commit:

git commit --cleanup=scissors

Two catches. The scissors rule only applies when you edit the message in an editor. With -m, Git keeps your text and only trims whitespace. And don’t delete the marker line while editing: without it, the hint lines Git added below can end up in your history. Run git log -1 after the first commit to see that it came out the way you expected.

Further reading: git-commit documentation, git-config 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 commit -m "Fix login redirect" -m "The old code sent signed-out users to a 404." Commit.template pre-fills your commit message All Commit tips (7) All topics

Link