SourceTree comments in commit message (starting with '#')

Jonathan Wiens
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 26, 2014

When using commit.template config (see https://answers.atlassian.com/questions/143622/git-config-commit-template-apparently-not-working) SourceTree reads the template file just fine. When committing, it doesn't ignore lines starting with '#' though, as it was designed by git.

In the terminal, when committing with a message that contains lines starting with a '#', git ignores those lines and does not make them part of the actual commit message. SourceTree on the other hand makes them part of the actual commit message.

Is this behaviour wanted? If yes, why?

I want commit message templates that explain where what goes, specifying keywords that dynamically interact with a project management platform (Redmine, http://www.redmine.org/projects/redmine/wiki/RedmineSettings#Referencing-issues-in-commit-messages) as comments that should be ignored in the actual commit message.

I'm currently working with SourceTree 1.5.2.0 on Windows 8 and system Git version 1.9.0

Thanks!

2 answers

1 accepted

4 votes
Answer accepted
Henrik Johansson
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2016

It is possible to configure the commit cleanup mode.

If you configure "commit.cleanup" to "strip", SourceTree will behave more as you would like ( "as it was designed by git" smile )

 

git config --add commit.cleanup strip

Jonathan Wiens
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2016

Perfect! Thanks

Johan Kaving
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2016

And the reason can be found in the documentation for the commit.cleanup option:

strip

Strip leading and trailing empty lines, trailing whitespace, commentary and collapse consecutive empty lines.

whitespace

Same as strip except #commentary is not removed.

...

default

Same as strip if the message is to be edited. Otherwise whitespace.

 

The crucial part is "is to be edited" in the description of the default setting.

When committing from the command line and letting Git open an editor the mode used will be "strip". But if you supply the commit message using "-m" or "-F" the "whitespace" mode will be used.

By looking at "Show Full Output" when committing from SourceTree you can see that the commit message is saved to a temporary file and supplied to Git using the "-F" option.

0 votes
Reto Ryter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 7, 2015

Same problem here.

Mac OSX Yosemite, SourceTree: Version 2.0.5.2 (2.0.5.2)

System Git version 2.3.0

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events