Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start a git commit message with a hashmark (#)

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.

like image 983
knittl Avatar asked May 07 '10 11:05

knittl


People also ask

What is git commit with flag A?

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.

Can I use Markdown in git commit?

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.


1 Answers

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.

like image 162
CB Bailey Avatar answered Sep 23 '22 16:09

CB Bailey