Reputation: 420
I'm using a git commit template to standard my commits, but the commented lines (start with #
) don't is erased after commit.
Can I configure the git gui
to disregard theses lines? I use git gui
as editor for commits.
I configure the the commit template using:
git config --global commit.template C:\Users\Name\.gitmessage
My .gitmessage
file:
#<-------------( Title: 50 chars )-------------->#
# Title/Summary/Imperative/Captilized/No period
# remember blank line between title and body
#<-------------( Body: wrap it to about 72 chars or so )-------------->#
# Body: Explain *what* and *why* (not *how*). Include task ID (issue).
# Explain the problem that this commit is solving. Focus on why you
# are making this change as opposed to how (the code explains that).
# Are there side effects or other unintuitive consequences of this
# change? Here's the place to explain them.
# <blank line>
# Co-authored-by: name <[email protected]>
The idea is that all the lines of the template are not included in the commit, the lines that start with #
are ignored.
EDIT:
Using the VS Code as the main editor works well.
$ git config --global core.editor "code --wait"
Upvotes: 3
Views: 213
Reputation: 1769
I had the same issue, it turns out the commit-msg
git hook is permitted to edit the message file in place. So I added the following hook to mine and now the comments in my template are removed properly via git gui:
#!/usr/bin/env bash
sed -i '/^[[:space:]]*#.*$/d' "$1"
Note: the actual logic of
git commit
does not remove lines where the#
isn't in the very first column, where as my example tolerates (only) white space before it.
Upvotes: 0