Why Commit is important ?

Commit messages are  the only way for you to communicate why your code has changed. This is for yourself, your coworkers or collaborators to use.

Best Practices 

Here are few of the  best practices for writing a good commit.

  1. Subject :
    1. Must contain type :
      1. feat : new feature
      2. fix : a bug fix
      3. docs : changes to documentation
      4. style : formatting change
      5. refactor :  refactoring of the production code
      6. test : added test or any test related commits.
      7. chore : any non production code and non test code related tasks such as library add, package manager config etc
    2. Short description of what changed (50 characters or less).
    3. Clear and informative
    4. First Letter capitalized (easy to follow)
    5. Imperative tone e.g change  instead of changed or changes
  2. Body :
    1. Optional to be used if commit subject needs to be more elaborative. Not every commit needs elaboration
    2. Must answer
      1. Why commited
  1. Footer: optional  and is used to reference issue tracker Ids

 

Example of good commit

feat: Summarize changes in around 50 characters or less

More detailed explanatory text, if necessary.

If you use an issue tracker, put references to them at the bottom. for example

Resolves: #123

See also: #456, #789

Reference: http://udacity.github.io/git-styleguide/

Advertisements