It is useful to write good commit message which shows professionalism. it shows whether a developer is a good collaborator or not?
The most basic element of keeping a healthy commit history: How to write a great commit message.
Just follow the seven rules below and you’re on your way to committing like a pro.
Though not required, it’s a good idea to begin the commit message with a single short (less than 50 character) 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.
- So shoot for 50 characters, but consider 72 the hard limit.
- This is as simple as it sounds. Begin all subject lines with a capital letter.
For example:
+ Accelerate to 88 miles per hour
Instead of:
- accelerate to 88 miles per hour
Trailing punctuation is unnecessary in subject lines. Besides, space is precious when you’re trying to keep them to 50 chars or less.
Example:
+ Open the pod bay doors
Instead of:
- Open the pod bay doors.
Imperative mood just means “spoken or written as if giving a command or instruction”. A few examples:
- Clean your room
- Close the door
- Take out the trash
Git itself uses the imperative whenever it creates a commit on your behalf.
So when you write your commit messages in the imperative, you’re following Git’s own built-in conventions. For example:
+ Refactor subsystem X for readability
+ Update getting started documentation
+ Remove deprecated methods
+ Release version 1.0.0
+ merge pull request #123 from user/branch
Insted of:
- Fixed bug with Y
- Changing behavior of X
- More fixes for broken stuff
- Sweet new API methods
Remember: Use of the imperative is important only in the subject line. You can relax this restriction when you’re writing the body.
The recommendation is to do this at 72 characters, so that Git has plenty of room to indent text while still keeping everything under 80 characters overall.
In most cases, you can leave out details about how a change has been made. Code is generally self-explanatory in this regard (and if the code is so complex that it needs to be explained in prose, that’s what source comments are for). Just focus on making clear the reasons why you made the change in the first place—the way things worked before the change (and what was wrong with that), the way they work now, and why you decided to solve it the way you did.