12/21/2017 - 2:03 PM

My thoughts on Git commit structure

My thoughts on Git commit structure

Git commit prefixes

When possible it is preferable to break up your commits into smaller digestable chunks so that they are more readable during the peer review process. One way to accomplish this is by using a known set of git commit prefixes.

  • [api]: New apis / changes to apis
  • [test]: Update test/* files
  • [dist]: Changes to submodules, version bumps, updates to package.json
  • [tiny]: Small changes#
  • [doc]: Updates to documentation
  • [ux]: Updates to UX
  • [fix]: Bug fixes
  • [bin]: Update binary scripts associated with the project
  • [merge]: Resolved git merge from upstream or otherwise
  • [refactor]: Refactor of existing code with no external API changes
  • [{{ feature }}]: Updates {{ feature }}

For example if you had done work on a new API for your project and added tests your commit would look something like this:

git add some-file.js
git add test/some-file.test.js
git commit -m '[api test] Added some feature along with associated tests.'