git commit -m”Best Practices”

All of us who use some kind of revision control system have this problem especially the one who are new to the whole git commit thing . Well the question I use to have what do I write what I just did and how can it be helpful to others.

I got all those question answered when I was working on moving my patch from master branch to feature branch. Pingou asked me to squash commits and make the commit message more reasonable.

Selection_005

Not so good way of writing a commit

Some of the references I used was Peter Hunter’s Blog and Chris Beam’s Blog. And I landed up with these seven rules .

The seven rules of a great git commit message

  1. Separate subject from body with a blank line
  2. Limit the subject line to 50 characters
  3. Capitalize the subject line
  4. Do not end the subject line with a period
  5. Use the imperative mood in the subject line
  6. Wrap the body at 72 characters
  7. Use the body to explain what and why vs. how

But for all the single commits which is doing a minor change you can still use git commit -m “your message”. ( Try to keep message in imperative mood)

Selection_006

A better way of writing commits

For bigger changes you need an editor so you might want to use a switch -a. For more details on how you can do that in pro git. Finally I am changing my habits of those shabby commit messages. So, think twice before you commit. 😉

Did you find this article valuable?

Support Farhaan Bukhsh by becoming a sponsor. Any amount is appreciated!