0

I feel stupid for asking this but here we go: When doing a git commit we can use one or more lines in the comment. My goal is to see just the first line in reporting as a summary, and to provide more detail that is only seen when looking at commit detail. For example, when you go to GitHub and look at a folder of source files, it shows the file name and the summary for the last commit. So you can see that the update N days ago was about 'foo' - it doesn't show the entire comment for the last commit for each file.

With two lines, the summary text will show line1_line2 << with the two lines delimited by a space, and then truncated depending on the space available. I've found that with a space after the first line, then CRLF, that the summary tends to show only line1, depending on where I look.

What I'm asking, is if there is a specific pattern that we should follow to ensure that summary line has only what we want, not some truncated version of line1_line2. And is there any other syntax in comments that is universally accepted? For example, the #00 syntax may/should link to the issue tracker related to a repo, but that's dependent on the platform. And I don't think there is a standard for markup within a comment, I think it must be plain text. I'm talking about generally accepted patterns like that. Thanks.

TonyG
  • 1,432
  • 12
  • 31
  • https://stackoverflow.com/search?q=%5Bgit%5D+commit+message+best+practice – phd Jan 11 '19 at 18:07
  • This is indeed a duplicate, I wasn't able to articulate a decent query to find other answers. Thanks @phd. – TonyG Jan 11 '19 at 21:58

1 Answers1

0

The summary is the first line, until CRLF, of the commit message. Just leave a blank line after the first line, and you should be fine. E.g.:

Subject line

The rest of the commit message. Since it's preceded by an empty line, it won't show up as part of the summary.

Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • you provided a good answer but since this is a duplicate question I need to flag it as such. The 50/72 note elsewhere explained a little better the formatting of the subject and detail. I saw another note that confirmed that a space at the end of the first line is intentionally an EOL signal. But your suggestion here about simply using an empty line2 is a pattern that I've followed, but you've confirmed that it's a good one. Thanks. – TonyG Jan 11 '19 at 22:01