Git treats lines starting with #
as comment lines when committing. This is very annoying when working with a ticket tracking system, and trying to write the ticket number at the beginning of the line, e.g.
#123 salt hashed passwords
Git will simply remove the line from the commit message. Is there a way to escape the hash? I tried \
and !
, but nothing works. Whitespace before #
is preserved, so that's not a working solution to the problem either.
Add/Commit All By using the -a flag when committing you are telling Git to add all files that have been modified and then commit them. This runs into issues with new files, though. Since the -a flag only adds modified files it will not add new files or deleted files.
Use Markdown to format your text. Some tools like GitHub will render Markdown when showing commit messages. Use asterisks bullets when you need to explain a long list of changes. The commit message should be clear on its own.
This behaviour is part of git commit
's default 'clean-up' behaviour. If you want to keep lines starting with #
you can use an alternative clean-up mode.
E.g.
git commit --cleanup=whitespace
If you do this you have to be careful to remove all #
lines that you don't want to appear in the commit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With