Used by hooks and editors to tidy commit messages.
Cleans up trailing whitespace and blank lines on stdin, with optional comment-stripping. Used by Git itself before storing commit messages and ideal for commit-msg hooks and editor plugins.
A small text filter with three jobs: trim trailing spaces on every line, collapse runs of blank lines, and optionally remove or convert comment lines. Reads stdin, writes stdout, never touches files.
git stripspace [-s | --strip-comments]
git stripspace [-c | --comment-lines]
| Flag | What it does |
|---|---|
-s, --strip-comments | Remove lines beginning with the comment character (default #) |
-c, --comment-lines | Prepend the comment character to every nonblank line |
(default) | Strip trailing whitespace and collapse multiple blank lines |
(stdin/stdout) | Always reads stdin, writes stdout - never edits files in place |
commit-msg hook before Git stores itgit stripspace < "$1" > "$1.tmp" && mv "$1.tmp" "$1"git stripspace --strip-comments < message.txtecho 'Edit above' | git stripspace --comment-linesgit -c core.commentChar=';' stripspace -s < message.txtcommit-msg hook; it's the cheapest way to enforce trailing-whitespace hygiene.core.commentChar by passing it through -c config rather than hardcoding #.--comment-lines when generating editor instructions so they auto-strip on commit.--strip-comments only strips lines starting at column 0 with the comment char; indented # is preserved.Hit each option, then Check answers. Score is recorded; Next is always open.