DEV Community

Jayesh Tembhekar ⚑
Jayesh Tembhekar ⚑

Posted on

Git commit message πŸ’¬

Hello, there πŸ‘‹πŸΌ I hope you are doing well.

As a developer, I know you are well aware of the Git version control system.

Just wanted to know:

How do you write your β–Ά

git commit -m "commit message"

Do you follow any special rule or something?
Let's discuss in the comment section below πŸ˜„

Top comments (19)

Collapse
 
shadowtime2000 profile image
shadowtime2000

I either use the conventional commits specification or just type what describes the commit best.

Collapse
 
mindset profile image
Jayesh Tembhekar ⚑

This is nice πŸ‘ŒπŸ»

Collapse
 
vuong profile image
vuong β›ˆοΈ

I have a template for Git commit in work which mentions the pattern of issue ID then it can be checking crossly with issues management tool by just a click, but just use the simple message for my personal stuffs.

Collapse
 
aftabksyed profile image
Aftab Syed

What template are you talking about and how do you implement/incorporate that template when committing the code?

Collapse
 
vuong profile image
vuong β›ˆοΈ

thoughtbot.com/blog/better-commit-... here is a tutorial. My template is just put the prefix string like ABC-, then whenever I commit code, I just put the number sequentially defined prefix and also commit message at the end.

Git commit template is also affected to Git-familiar-tools like VScode/Fork.

Collapse
 
jcubic profile image
Jakub T. Jankiewicz

There are rules how to write them correctly by design of git, they are probably invented by Linus Torvalds author of git.
The message should look like this:

short sentence that describe the change

Detail description why the change was needed. You don't need to write
what was changed since that is inside the commit itself. But rationale
is important, so you can benefit why the change happen.
Enter fullscreen mode Exit fullscreen mode

also the first sentence should be shorter (not sure exactly how many characters).

I'm trying to write commit message like this if there are reason why something was changed. This is important specially with big projects and lot of changes where you don't know other part of the code. The message should be the clue.

Collapse
 
curtisl profile image
Curtis Lawrence

A while back I adopted this format for an angular project, which is basically the Angular commit format It became muscle memory and has essentially become my standard.

<type>(<scope>): <subject>
<BLANK LINE>
<description>
Enter fullscreen mode Exit fullscreen mode
Collapse
 
irgeek profile image
James Sinclair

I always start with a short and descriptive sentence -- including a period -- which still makes sense if prefixed with "Apply this commit to ". The only exception being the very first commit which can be something like "Initial commit." This requirement is incompatible with adding Issue ID/category/scope/whatever prefixes to commit messages. I don't think they add any value and they usually just end up being a distraction when you're looking at a list of commits.

After the short, descriptive sentence (and a blank line) you can include whatever you like in more detail. Use Markdown if you want formatting, but consider whether it's really important in this context. I generally only use asterisks for unordered lists when I want to detail several changes in a commit. Issue IDs/categories/scopes belong here, possibly in a block of YAML at the end.

Collapse
 
melezhik profile image
Alexey Melezhik • Edited

a couple of things:

The whole flow is available through the Tomtit task runner - github.com/melezhik/Tomtit#profiles

 tom --profile git
 tom commit
 tom push
Enter fullscreen mode Exit fullscreen mode

Or

 tom git-publish
Enter fullscreen mode Exit fullscreen mode
Collapse
 
shrihankp profile image
Shrihan

My format is:
git commit -m "$SUPPORTING_EMOJI:$TYPE_OF_COMMIT: $COMMIT_DESCRIPTION"

Collapse
 
jcolag profile image
John Colagioia (he/him) • Edited

With a few exceptions, I'm another one conditioned that the first line is a command: "Fix the parsing," "Begin implementing lighting feature," and so forth, and should fit in sixty characters, so that it (mostly) won't wrap when people check the logs on a console. After the first line, it's a free-for-all.

That said, the right answer is always "whatever the shop does," because we're cooperating on projects, not off doing our own things and just hoping they fit back together.

Collapse
 
fpcorso profile image
Frank Corso

I have had a few projects where it was required to follow these rules: chris.beams.io/posts/git-commit/

Basically boils down to having an imperative statement with no period that is less than 50 characters for the subject and then lines of 72 characters or less for the body with subject and body being separated by a blank line.

Of course, ending with an Issue #XXX when relevant to tie the commit to an issue on GitHub.

After doing it that way for a bit, I now mostly follow a similar structure for most commits on all projects.

Collapse
 
akhterali profile image
Mo Ali

[PROJECT-TICKET] Tasks completed in present tense

Collapse
 
amplanetwork profile image
Ampla Network

Describe what I will push... What to say... πŸ˜„

Collapse
 
codefinity profile image
Manav Misra

Start with a verb in the imperative/present tense. Follow with a short sentence describing the task that just occurred - no period at end.
Might also use Gitmoji

Collapse
 
angelmtztrc profile image
Angel Martinez

I recently started using emojis in my commits, they really look good, this is an example:

✨feature(scope): a short description of the feature

But, I really want to see other good ideas for commits

Collapse
 
mindset profile image
Jayesh Tembhekar ⚑

I also ❀ emojis

Collapse
 
mohamed351 profile image
Mohamed Beshri Amer

I always do this kind of stuff when the team leader. we need to publish right now

Collapse
 
mohamed351 profile image
Mohamed Beshri Amer

by the way, we work on TFS