Sign in
Log inSign up
Simon Egersand 馃巿

234 likes

5.8K reads

26 comments

Rafael B. Pires
Rafael B. Pires
Jul 3, 2022

Great and insightful overview... straight to the point! Thanks for sharing

2
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 3, 2022

Thank you, Rafael! Glad you liked it :)

1
Prafful Javare
Prafful Javare
Jul 3, 2022

Loved these tips. I have been following the "imperative mood" styling ever since I read it in the contribution guide of a public repository. I usually use the vscode git extension for my commits, so can I separate the title from the body by adding a line break?

2
4 replies
Rafael B. Pires
Rafael B. Pires
Jul 3, 2022

Hey Prafful, how are you? By VS Code extension do you mean the native source control tab? If so, I've learned recently that you can use enter to normally add multiple lines to the commit message before using ctrl+enter to submit. The first line would be considered the title and every line after would correspond to the description. In fact, Git per se doesn't differentiate title and description, these meanings are given by users/conventions.

1
Prafful Javare
Prafful Javare
Jul 4, 2022

Understood. Thanks Rafael B. Pires! I thought commits also have titles and bodies similar to pull requests 馃

Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 4, 2022

Prafful Javare

Hi. Yes, indeed Git does have a subject line ("title") as well as a body ("description"). I don't use VSCode so I don't know about that but when you use Git in the CLI you separate subject line and body with a newline. This is most likely what you need to do in VSCode as well :)

2
Rafael B. Pires
Rafael B. Pires
Jul 9, 2022

Simon, what I meant by Git doesn't differentiate title and description is that it's not required by default, but by good practices (which can include, also, the footer).

Here's what the docs say: "Though not required, it鈥檚 a good idea to begin the commit message with a single short (less than 50 characters) line summarizing the change, followed by a blank line and then a more thorough description. The text up to the first blank line in a commit message is treated as the commit title, and that title is used throughout Git." (git-scm.com/docs/git-commit#_discussion)

It's said that this soft rule was established from the analysis of the commits in the kernel codebase.

In fact, you can (and should) concatenate paragraphs, but you can also type just one very long commit message with all the descriptions, which is not recommended at all and would make the git log unreadable 馃槄

So, initially, the title and description are nothing more than just the first line, and the rest of the lines in the commit message, usually separated by a blank line, by convention. But, as you said, there's a subject line indeed 馃槍

I thought this could make it clearer for Prafful to visualize the usage in VS Code, but it made it more difficult instead. My bad, sorry!

1
Chijioke Chika
Chijioke Chika
Jul 3, 2022

Informative, thanks for sharing.

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 3, 2022

Thanks, Chijioke!

Antonin H茅rault
Antonin H茅rault
Jul 3, 2022

Useful and well-written, Thank you

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 4, 2022

:) Thank you, Antonin.

1
trav
trav
Jul 4, 2022

I always struggle to write meaningful commits, thanks for this!

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 4, 2022

Hi Travis! I struggle too at times. This usually means I'm committing too much at once, and I split up the commit into two or more. Hope this was useful :)

1
Saanvi
Saanvi
Jul 4, 2022

Very Insightful...!!

1
Saanvi
Saanvi
Jul 4, 2022

Awesome article. Thanks a lot for sharing.

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 4, 2022

Thanks a lot, Saanvi! :)

Ammaar Aslam
Ammaar Aslam
Jul 4, 2022

Great content! Thanks for sharing 馃ぉ

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 4, 2022

Appreciate it, Ammaar! :)

1
Roshith R
Roshith R
Jul 5, 2022

Great

1
Yahaya Oyinkansola
Yahaya Oyinkansola
Jul 5, 2022

What stood out for me was when you said my commit messages should explain why and not what, a really good mindset shift, thanks a lot!

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 6, 2022

Glad you like it, Yahaya! :)

Ijeoma Igboagu
Ijeoma Igboagu
Jul 5, 2022

Thanks for Sharing

1
The Revealer
The Revealer
Jul 5, 2022

Short, straight to the point and excellent.

I love your work here man馃憦馃憦馃憦馃憦.

1
1 reply
Simon Egersand 馃巿
Simon Egersand 馃巿
Author
Jul 6, 2022

Thanks so much! I appreciate your kind words :)

Abubakar Shuaib
Abubakar Shuaib
Jul 6, 2022

Awesome

1
Sy Hung Doan
Sy Hung Doan
Jul 30, 2022

Hey could you write some more examples of 'imperative mood'? I kinda get the idea, but do not really get how to write a good one.