Problem
Multi-line commit messages entered through the JetBrains IDE Git client are truncated, and any line starting with the # character is removed from the final commit. Issue references such as #5 written on a separate line do not appear in the resulting commit.
Example commit message entered in the IDE Commit tool window:
fix: Add logging file
#5
Resulting commit message after commit:
fix: Add logging file
Cause
When a Git commit template is configured (via commit.template in .gitconfig), JetBrains IDEs invoke git commit with the --cleanup=strip option to remove template comment lines from the final commit.
The --cleanup=strip mode removes every line that begins with the configured Git comment character — # by default — including content added intentionally by the user.
Resolution
Use one of the following approaches:
Add a non-comment prefix to the line
Prefix the issue reference with any text so that the line does not start with #:
fix: Add logging file
Issue: #5
Change the Git comment character
Configure Git to use a different comment character so that # can appear at the start of a commit-message line:
git config --global core.commentChar ";"
After this change, only lines starting with ; are treated as comments and stripped. See the core.commentChar documentation.
Comments
0 comments
Please sign in to leave a comment.