git commit -m”Best Practices”

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. ๐Ÿ˜‰

Advertisements

2 thoughts on “git commit -m”Best Practices”

  1. Very Good article on Committing

    Well there is a small correction “git commit” opens your configured editor (default it’s vi) for typing the commit message.

    -a flag is to say to add the previously added files in the commit too if modified with out the need to adding them by using git add filename

    so you can also git the commit message like this

    git commit -a -m “msg”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s