Reputation: 6345
I have staged a file readme.txt
. When invoking
$ git commit
it opens my editor with a predefined message (the |
in the first line I've added only to force stackoverflow to show this empty line):
|
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
# modified: readme.txt
#
# Untracked files:
# message.txt
#
so I can enter the message
add readme.txt
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch master
# Changes to be committed:
# modified: readme.txt
#
# Untracked files:
# message.txt
#
save and exit, the commit will be created with the message add readme.txt
.
However, when having the same content in a file message.txt
(including the #
lines) and running
$ git commit --file message.txt
the commit will have the full content of the file as message, including all the comments.
How to tell Git to ignore the #
lines in the specified message file as it does without the --file <message-file>
parameter?
Upvotes: 4
Views: 65
Reputation: 13387
This would then be
git stripspace --strip-comments < message.txt |
git commit --file -
Upvotes: 4