Skip to main content

Commit Standards

A commit combines changes into a logical unit. Adding a descriptive commit message can identify the code changes. Remember the following things when making a commit:

  • It's a good to make small commits. This makes changes easier to review and allows you to revert only the last changes if you discover a problem and also neatly explains exactly what changes were made and why. Split the commits into separate commits if it includes more than one logical changes or bug fix.
  • Don't mix whitespace changes with functional code changes. It is hard to determine if the line has a functional change or only removes a whitespace, so functional changes may go unnoticed.
  • Never commit incomplete code, its good to testing your code before committing.
  • Write good commit messages. Use the imperative style in the subject line.
  • Before making commits, ask yourself Why did I add this commit? and What changes does this commit make?

Structure

  • subject: a short description of the commit, maximum 50 characters long.
    • subject must not be ['sentence-case', 'start-case', 'pascal-case', 'upper-case']
  • body (optional): a longer description of the commit includes what, why and how, wrapped at 72 characters, separated from the subject line by a blank line
<type>: <description>

[optional body]

[optional footer]

Type of commits

TypeUsecase
featThe new feature you're adding to a particular application
fixBug Fix
styleFeature and updates related to styling
testEverything related to testing
docsChanges made on the documentation, readme.md or markdown files
choreCode maintenance such as modification or updating dependencies

Example of a commit message:

git commit -m "fix: commit Message"

References

Conventional Commits